Repository navigation
[CALCITE-7978] RelMdColumnUniqueness can incorrectly infer that an Aggregate preserves the uniqueness of input column combinations - #5465
Open
zzwqqq wants to merge 1 commit into
Conversation
…gregate preserves the uniqueness of input column combinations
mihaibudiu
reviewed
Nov 29, 2026
| .assertThatAreColumnsUnique(bitSetOf(0, 2), is(false)) | ||
| .assertThatAreColumnsUnique(bitSetOf(0, 3), is(true)) | ||
| .assertThatAreColumnsUnique(bitSetOf(0, 4), is(true)) | ||
| .assertThatAreColumnsUnique(bitSetOf(0, 3), is(false)) |
Contributor
There was a problem hiding this comment.
I think that @PaulJackson123 has added these tests, maybe he can provide a review?
Contributor
|
This is a pretty serious bug, so hopefully we can fix it quickly. |
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-7978
Changes Proposed
RelMdColumnUniquenessandRelMdUniqueKeyscan incorrectly infer that aggregate results form a key when their input columns form a key. Separate calls can select values from different rows in a group, so two groups can produce the same combination.I propose using
canPassThroughKeyin both handlers. For a simpleGROUP BYwith unfiltered pass-through aggregates, either condition lets each group return the full input key from one row.If neither condition holds,
getUniqueKeysskips that key.areColumnsUniquestill checks the selected grouping columns with one non-grouping argument at a time.