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

Method doc_select

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

Source from the content-addressed store, hash-verified

1147 }
1148
1149 fn doc_select<'a, T: AstInfo>(&'a self, v: &'a Select<T>) -> RcDoc<'a> {
1150 let mut docs = vec![];
1151 let mut select = RcDoc::text("SELECT");
1152 if let Some(distinct) = &v.distinct {
1153 select = nest(select, self.doc_distinct(distinct));
1154 }
1155 docs.push(nest_comma_separate(
1156 select,
1157 |s| self.doc_select_item(s),
1158 &v.projection,
1159 ));
1160 if !v.from.is_empty() {
1161 docs.push(title_comma_separate(
1162 "FROM",
1163 |t| self.doc_table_with_joins(t),
1164 &v.from,
1165 ));
1166 }
1167 if let Some(selection) = &v.selection {
1168 docs.push(nest_title("WHERE", self.doc_expr(selection)));
1169 }
1170 if !v.group_by.is_empty() {
1171 docs.push(title_comma_separate(
1172 "GROUP BY",
1173 |e| self.doc_expr(e),
1174 &v.group_by,
1175 ));
1176 }
1177 if let Some(having) = &v.having {
1178 docs.push(nest_title("HAVING", self.doc_expr(having)));
1179 }
1180 if let Some(qualify) = &v.qualify {
1181 docs.push(nest_title("QUALIFY", self.doc_expr(qualify)));
1182 }
1183 if !v.options.is_empty() {
1184 docs.push(bracket(
1185 "OPTIONS (",
1186 comma_separate(|o| self.doc_display_pass(o), &v.options),
1187 ")",
1188 ));
1189 }
1190 RcDoc::intersperse(docs, Doc::line()).group()
1191 }
1192
1193 fn doc_select_item<'a, T: AstInfo>(&'a self, v: &'a SelectItem<T>) -> RcDoc<'a> {
1194 match v {

Callers 1

doc_set_exprMethod · 0.80

Calls 14

nestFunction · 0.85
nest_comma_separateFunction · 0.85
title_comma_separateFunction · 0.85
nest_titleFunction · 0.85
bracketFunction · 0.85
comma_separateFunction · 0.85
doc_distinctMethod · 0.80
doc_select_itemMethod · 0.80
doc_table_with_joinsMethod · 0.80
doc_exprMethod · 0.80
doc_display_passMethod · 0.80
groupMethod · 0.80

Tested by

no test coverage detected