MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / parse_project_or_agg

Function parse_project_or_agg

crates/sql-parser/src/parser/mod.rs:125–152  ·  view source on GitHub ↗

Parse a SELECT clause with only a single item

(item: SelectItem)

Source from the content-addressed store, hash-verified

123
124/// Parse a SELECT clause with only a single item
125pub(crate) fn parse_project_or_agg(item: SelectItem) -> SqlParseResult<Project> {
126 match item {
127 SelectItem::Wildcard(WildcardAdditionalOptions {
128 opt_exclude: None,
129 opt_except: None,
130 opt_rename: None,
131 opt_replace: None,
132 }) => Ok(Project::Star(None)),
133 SelectItem::QualifiedWildcard(
134 table_name,
135 WildcardAdditionalOptions {
136 opt_exclude: None,
137 opt_except: None,
138 opt_rename: None,
139 opt_replace: None,
140 },
141 ) => Ok(Project::Star(Some(parse_ident(table_name)?))),
142 SelectItem::UnnamedExpr(Expr::Function(_)) => Err(SqlUnsupported::AggregateWithoutAlias.into()),
143 SelectItem::ExprWithAlias {
144 expr: Expr::Function(agg_fn),
145 alias,
146 } => parse_agg_fn(agg_fn, alias.into()),
147 SelectItem::UnnamedExpr(_) | SelectItem::ExprWithAlias { .. } => {
148 Ok(Project::Exprs(vec![parse_project_elem(item)?]))
149 }
150 item => Err(SqlUnsupported::Projection(item).into()),
151 }
152}
153
154/// Parse an aggregate function in a select list
155fn parse_agg_fn(agg_fn: Function, alias: SqlIdent) -> SqlParseResult<Project> {

Callers 1

parse_projectionFunction · 0.85

Calls 5

StarClass · 0.85
parse_identFunction · 0.85
parse_agg_fnFunction · 0.85
OkFunction · 0.50
ErrFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…