mingmwang commented on PR #4365:
URL:
https://github.com/apache/arrow-datafusion/pull/4365#issuecomment-1331609471
> > You can try this: select (a + b) as c, count(*) from Table_A group by 1
>
> ```rust
> #[test]
> fn push_down_filter_groupby_expr_contains_alias() {
> let sql = "SELECT (col_int32 + col_uint32) AS c, count(*) from test
group by 1";
> let plan = test_sql(sql).unwrap();
> let expected = "Projection: test.col_int32 + test.col_uint32 AS c,
COUNT(UInt8(1))\
> \n Aggregate: groupBy=[[test.col_int32 + CAST(test.col_uint32 AS
Int32)]], aggr=[[COUNT(UInt8(1))]]\
> \n TableScan: test projection=[col_int32, col_uint32]";
> assert_eq!(expected, format!("{:?}", plan));
> }
> ```
>
> current implementation will put alias into projection expr
>
> run in integration test. exist bug #4430, run it need to remove bug rule.
>
> ```rust
> #[test]
> #[ignore]
> // TODO: UnwrapCastInComparison exist bug.
> fn push_down_filter_groupby_expr_contains_alias() {
> let sql = "SELECT * FROM (SELECT (col_int32 + col_uint32) AS c,
count(*) FROM test GROUP BY 1) where c > 3";
> let plan = test_sql(sql).unwrap();
> let expected = "Projection: c, COUNT(UInt8(1))\
> \n Projection: test.col_int32 + test.col_uint32 AS c, COUNT(UInt8(1))\
> \n Aggregate: groupBy=[[test.col_int32 + CAST(test.col_uint32 AS
Int32)]], aggr=[[COUNT(UInt8(1))]]\
> \n Filter: CAST(test.col_int32 + test.col_uint32 AS Int64) >
Int64(3)\
> \n TableScan: test projection=[col_int32, col_uint32]";
> assert_eq!(expected, format!("{:?}", plan));
> }
> ```
Ok, got it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]