zhuqi-lucas commented on PR #15532:
URL: https://github.com/apache/datafusion/pull/15532#issuecomment-2775156329
Thank you @andygrove @berkaysynnada , i believe we need more effort if we
want to support such as sum(a + b) => sum(a) + sum(b).
**Need help, i am not sure if i do the right direction for this ticket:**
I am still debugging my draft PR, if folks can cooperate, feel free to add a
fix to my PR because it will meet more corner cases i believe, and i am still
not fixing the existing error:
https://github.com/apache/datafusion/pull/15532
More problems need to be fixed based on my PR, for example:
- [ ] It seems, simplify_expressions will change the sum(a + b) => sum(a) +
sum(b), so the error happens:
```rust
logical_plan after simplify_expressions
01)Projection: sum(simple_explain_test.a + simple_explain_test.b)
02)--Aggregate: groupBy=[[]], aggr=[[sum(simple_explain_test.a) +
sum(simple_explain_test.b) AS sum(simple_explain_test.a +
simple_explain_test.b)]]
03)----TableScan: simple_explain_test
```
```rust
logical_plan
01)Aggregate: groupBy=[[]], aggr=[[sum(simple_explain_test.a) +
sum(simple_explain_test.b) AS sum(simple_explain_test.a +
simple_explain_test.b)]]
02)--TableScan: simple_explain_test projection=[a, b]
physical_plan_error
01)Internal error: Invalid aggregate expression 'BinaryExpr(BinaryExpr {
left: AggregateFunction(AggregateFunction { func: AggregateUDF { inner: Sum {
signature: Signature { type_signature: UserDefined, volatility: Immutable } }
}, params: AggregateFunctionParams { args: [Column(Column { relation: Some(Bare
{ table: "simple_explain_test" }), name: "a" })], distinct: false, filter:
None, order_by: None, null_treatment: None } }), op: Plus, right:
AggregateFunction(AggregateFunction { func: AggregateUDF { inner: Sum {
signature: Signature { type_signature: UserDefined, volatility: Immutable } }
}, params: AggregateFunctionParams { args: [Column(Column { relation: Some(Bare
{ table: "simple_explain_test" }), name: "b" })], distinct: false, filter:
None, order_by: None, null_treatment: None } }) })'.
02)This was likely caused by a bug in DataFusion's code and we would welcome
that you file an bug report in our issue tracker
```
- [ ] Some unit tests are failing, need to investigate.
- [ ] Need to check if the datatype changes, it is still correct for the
rewrite.
- [ ] etc
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]