Repository navigation
[CALCITE-7885] RelDecorrelator merges distinct correlation fields and produces extra rows - #5353
Merged
Merged
Conversation
iwanttobepowerful
approved these changes
Oct 23, 2026
Contributor
|
Since this is a bug which can produce incorrect results, I plan to merge it rather soon - given there is already an approval. |
mihaibudiu
reviewed
Oct 23, 2026
| !ok | ||
| !set expand false | ||
|
|
||
| # [CALCITE-7885] RelDecorrelator merges distinct correlation fields and produces extra rows |
Contributor
There was a problem hiding this comment.
I checked this using Postgres.
Contributor
|
I will resolve the conflict and then hopefully merge once CI passes |
… produces extra rows
mihaibudiu
force-pushed
the
fix/correlated-scalar-aggregate
branch
from
October 23, 2026 18:22
68fc01f to
d513f59
Compare
Contributor
|
Took the liberty to push the fix to your branch. |
|
Member
Author
|
Thanks @iwanttobepowerful and @mihaibudiu for reviewing and getting this merged! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Jira Link
CALCITE-7885
Changes Proposed
rewriteScalarAggregateuses aggregate column positions as keys innewProjectMap. Different outer references can share a position, so one overwrites another. When their values differ on unmatched rows, the final join can attach an aggregate result to the wrong outer row.Rebuild the projection with correlation fields from
valueGen, followed by the original aggregate outputs. UpdatecorDefOutputsandoutputMapto match the new positions, preserving each outer reference and COUNT's zero result for empty input.