Fix incorrect Schema over aggregate function, Remove unnecessary exprlist_to_fields_aggregate
#10408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #10346.
Rationale for this change
exprlist_to_fields_aggregate was introduced by #2486.
It was necessary for the test
aggregate_with_rollup_with_grouping
.datafusion/datafusion/core/src/sql/planner.rs
Lines 4698 to 4705 in 5335f80
In this test, the grouped-by expression
person.state
was not included in the aggregate's output schema, so we need to further check the aggregate's input, as mentioned in the comments.But on the current main branch,
person.state
is already included in the aggregate's output schema, which is achieved through the function grouping_set_to_exprlist. It adds all the grouped-by expressions.datafusion/datafusion/expr/src/logical_plan/plan.rs
Line 2273 in c8b8c74
Therefore,
exprlist_to_fields_aggregate
should become unnecessary. Besides, it takes columns from the aggregate's input and might override a column with the same name in the output, leading to the bug in #10346..What changes are included in this PR?
Remove the unnecessary
exprlist_to_fields_aggregate
and fix a bug.Are these changes tested?
Yes
Are there any user-facing changes?
No