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

Method doc_create_table

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

Source from the content-addressed store, hash-verified

193 }
194
195 pub(crate) fn doc_create_table<'a, T: AstInfo>(
196 &'a self,
197 v: &'a CreateTableStatement<T>,
198 ) -> RcDoc<'a> {
199 let mut docs = Vec::new();
200
201 // CREATE [TEMPORARY] TABLE [IF NOT EXISTS] name
202 let mut title = "CREATE ".to_string();
203 if v.temporary {
204 title.push_str("TEMPORARY ");
205 }
206 title.push_str("TABLE");
207 if v.if_not_exists {
208 title.push_str(" IF NOT EXISTS");
209 }
210
211 // Table name and columns/constraints
212 let mut col_items = Vec::new();
213 col_items.extend(v.columns.iter().map(|c| self.doc_display_pass(c)));
214 col_items.extend(v.constraints.iter().map(|c| self.doc_display_pass(c)));
215
216 let table_def = nest(
217 self.doc_display_pass(&v.name),
218 bracket("(", comma_separated(col_items), ")"),
219 );
220 docs.push(nest_title(title, table_def));
221
222 // WITH options
223 if !v.with_options.is_empty() {
224 docs.push(bracket(
225 "WITH (",
226 comma_separate(|wo| self.doc_display_pass(wo), &v.with_options),
227 ")",
228 ));
229 }
230
231 RcDoc::intersperse(docs, Doc::line()).group()
232 }
233
234 pub(crate) fn doc_create_table_from_source<'a, T: AstInfo>(
235 &'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