Parse a SELECT clause with only a single item
(item: SelectItem)
| 123 | |
| 124 | /// Parse a SELECT clause with only a single item |
| 125 | pub(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 |
| 155 | fn parse_agg_fn(agg_fn: Function, alias: SqlIdent) -> SqlParseResult<Project> { |
no test coverage detected
searching dependent graphs…