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

Function parse_agg_fn

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

Parse an aggregate function in a select list

(agg_fn: Function, alias: SqlIdent)

Source from the content-addressed store, hash-verified

153
154/// Parse an aggregate function in a select list
155fn parse_agg_fn(agg_fn: Function, alias: SqlIdent) -> SqlParseResult<Project> {
156 fn is_count(name: &ObjectName) -> bool {
157 name.0.len() == 1
158 && name
159 .0
160 .first()
161 .is_some_and(|Ident { value, .. }| value.to_lowercase() == "count")
162 }
163 match agg_fn {
164 Function {
165 name,
166 args,
167 over: None,
168 distinct: false,
169 special: false,
170 order_by,
171 } if is_count(&name)
172 && order_by.is_empty()
173 && args.len() == 1
174 && args
175 .first()
176 .is_some_and(|arg| matches!(arg, FunctionArg::Unnamed(FunctionArgExpr::Wildcard))) =>
177 {
178 Ok(Project::Count(alias))
179 }
180 agg_fn => Err(SqlUnsupported::Aggregate(agg_fn).into()),
181 }
182}
183
184/// Parse an item in a SELECT clause
185pub(crate) fn parse_project_elem(item: SelectItem) -> SqlParseResult<ProjectElem> {

Callers 1

parse_project_or_aggFunction · 0.85

Calls 5

is_countFunction · 0.85
OkFunction · 0.50
ErrFunction · 0.50
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…