You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[test]
fnaggregate_with_alias() -> Result<()> {
letresults = execute("SELECT c1, COUNT(c2) AS count FROM test GROUP BY c1", 4)?;
assert_eq!(field_names(batch), vec!["c1", "count"]);
letexpected = vec!["0,10", "1,10", "2,10", "3,10"];
letmutrows = test::format_batch(&batch);
rows.sort();
assert_eq!(rows, expected);
Ok(())
}
The root cause is that, in sql::planner, we interpret COUNT(c2) AS count as An Expr::Alias, which fails the is_aggregate_expr condition, thus being interpreted as grouped expression instead of an aggregated expression. This raises the Error
The planner could interpret the statement above as two steps: an aggregation followed by a projection. Alternatively, we can allow aliases to be valid aggregation expressions.
The following test (on execute) fails:
The root cause is that, in
sql::planner
, we interpretCOUNT(c2) AS count
as AnExpr::Alias
, which fails theis_aggregate_expr
condition, thus being interpreted as grouped expression instead of an aggregated expression. This raises the ErrorGeneral("Projection references non-aggregate values")
The planner could interpret the statement above as two steps: an aggregation followed by a projection. Alternatively, we can allow aliases to be valid aggregation expressions.
Reporter: Jorge Leitão / @jorgecarleitao
Related issues:
PRs and other links:
Note: This issue was originally created as ARROW-9520. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: