[CALCITE-7439] Qualify GROUP BY keys for DISTINCT over joins#4829
Draft
bvolpato wants to merge 1 commit intoapache:mainfrom
Draft
[CALCITE-7439] Qualify GROUP BY keys for DISTINCT over joins#4829bvolpato wants to merge 1 commit intoapache:mainfrom
bvolpato wants to merge 1 commit intoapache:mainfrom
Conversation
ae686b6 to
be816c1
Compare
8805604 to
0558ef1
Compare
0558ef1 to
67bc8f8
Compare
67bc8f8 to
b6af6a8
Compare
|
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.



Summary
RelToSqlConverter emitted an ambiguous GROUP BY key after semi-join rewrites for a DISTINCT query over LEFT JOIN ... USING.
Reproduction query
Error before this PR
Fix
When building GROUP BY keys (and corresponding SELECT keys), qualify one-part identifiers against the SQL join side alias when the aggregate source is a join-shaped input.
Test
RelToSqlConverterTest.testPostgresqlRoundTripDistinctLeftJoinInSubqueryWithSemiJoinRulesGROUP BY "t2"."product_id"./gradlew :core:test --tests org.apache.calcite.rel.rel2sql.RelToSqlConverterTestDisclaimer
The changes were done with the assistance of Codex (gpt-5.3-codex) in response to an actual bug when using Calcite in production. The changes were manually verified prior to sending this to review.