MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / doc_create_subsource

Method doc_create_subsource

src/sql-pretty/src/doc.rs:395–433  ·  view source on GitHub ↗
(
        &'a self,
        v: &'a CreateSubsourceStatement<T>,
    )

Source from the content-addressed store, hash-verified

393 }
394
395 pub(crate) fn doc_create_subsource<'a, T: AstInfo>(
396 &'a self,
397 v: &'a CreateSubsourceStatement<T>,
398 ) -> RcDoc<'a> {
399 let mut docs = Vec::new();
400
401 // CREATE SUBSOURCE [IF NOT EXISTS] name
402 let mut title = "CREATE SUBSOURCE".to_string();
403 if v.if_not_exists {
404 title.push_str(" IF NOT EXISTS");
405 }
406
407 // Table name with columns/constraints
408 let mut col_items = Vec::new();
409 col_items.extend(v.columns.iter().map(|c| self.doc_display_pass(c)));
410 col_items.extend(v.constraints.iter().map(|c| self.doc_display_pass(c)));
411
412 let table_def = nest(
413 self.doc_display_pass(&v.name),
414 bracket("(", comma_separated(col_items), ")"),
415 );
416 docs.push(nest_title(title, table_def));
417
418 // OF SOURCE
419 if let Some(of_source) = &v.of_source {
420 docs.push(nest_title("OF SOURCE", self.doc_display_pass(of_source)));
421 }
422
423 // WITH options
424 if !v.with_options.is_empty() {
425 docs.push(bracket(
426 "WITH (",
427 comma_separate(|wo| self.doc_display_pass(wo), &v.with_options),
428 ")",
429 ));
430 }
431
432 RcDoc::intersperse(docs, Doc::line()).group()
433 }
434
435 pub(crate) fn doc_create_cluster<'a, T: AstInfo>(
436 &'a self,

Callers 1

to_docMethod · 0.80

Calls 13

nestFunction · 0.85
bracketFunction · 0.85
nest_titleFunction · 0.85
comma_separateFunction · 0.85
doc_display_passMethod · 0.80
groupMethod · 0.80
comma_separatedFunction · 0.70
to_stringMethod · 0.45
extendMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected