[BugFix] Fix shared object mutation in PushDownAggregateRewriter for case-when/if#71309
[BugFix] Fix shared object mutation in PushDownAggregateRewriter for case-when/if#71309lxynov wants to merge 2 commits intoStarRocks:mainfrom
Conversation
|
@codex review |
When pushing down an aggregate whose argument is a nested case-when/if, the previous code failed to add the inner condition columns to group-bys.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da35ed69fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
fe/fe-core/src/test/java/com/starrocks/sql/plan/AggregatePushDownTest.java
Show resolved
Hide resolved
fe/fe-core/src/test/java/com/starrocks/sql/plan/AggregatePushDownTest.java
Show resolved
Hide resolved
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 32 / 32 (100.00%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
|
Thanks @stdpain for adding another fix. It's fixing a separate bug. Would recommend creating another commit when merging or changing the squashed commit's message. |
|
After this PR is merged, could you help backport it to |
|
https://github.com/Mergifyio backport branch-3.5-cc |
🟠 Waiting for conditions to matchDetails
|
Why I'm doing:
When pushing down an aggregate whose argument is a nested case-when/if,
PushDownAggregateCollectordidn't add the inner condition columns to the group-by list, causing a query failure.The issue can be reproduced by the below query:
It fails with
What I'm doing:
Issue Analysis
The above SQL produces nested IF projections:
When the collector visits the
LogicalProjectOperatorwith15: case, it rewrites the aggregation tothen it correctly adds
t1ato the group-by columns.Later, when the collector visits
LogicalProjectOperatorwith11: case, it rewrites the aggregation toBut this time, it doesn't see
t1bin the "condition" columns, so it doesn't addt1binto the group-by columns.This behavior is different than the rewriter's behavior.
When the collector and the rewriter see different group-by lists, the pushdown fails. However, the rewriter works in a top-down manner ---- it rewrites nodes above first, then it aborts on the table scan ---- this produces an incorrect plan.
Fix
Modify the collector to add inner case-when/if's condition columns into the group-by list as well.
For the above query, this is the aggregate pushdown's behavior today:
Before the pushdown:
After the pushdown:
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: