You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/10/01 21:13:00 UTC
[jira] [Updated] (ARROW-9520) [Rust] [DataFusion] Can't alias an
aggregate expression
[ https://issues.apache.org/jira/browse/ARROW-9520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated ARROW-9520:
----------------------------------
Labels: pull-request-available (was: )
> [Rust] [DataFusion] Can't alias an aggregate expression
> -------------------------------------------------------
>
> Key: ARROW-9520
> URL: https://issues.apache.org/jira/browse/ARROW-9520
> Project: Apache Arrow
> Issue Type: Bug
> Components: Rust - DataFusion
> Reporter: Jorge Leitão
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The following test (on execute) fails:
> {code}
> #[test]
> fn aggregate_with_alias() -> Result<()> {
> let results = execute("SELECT c1, COUNT(c2) AS count FROM test GROUP BY c1", 4)?;
> assert_eq!(field_names(batch), vec!["c1", "count"]);
> let expected = vec!["0,10", "1,10", "2,10", "3,10"];
> let mut rows = test::format_batch(&batch);
> rows.sort();
> assert_eq!(rows, expected);
> Ok(())
> }
> {code}
> 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
> {{General("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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)