[CALCITE-4512] GROUP BY expression with argument name same with SELECT field and alias causes validation error #3929
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.
What changes were proposed in this pull request?
Stop identifiers in a SQL call from being treated as aliases and expanded into select expressions.
For example:
select replace(name, 'a', 'b') as name from users group by replace(name, 'a', 'b')
The name in GROUP BY clause should not be replaced by
replace(name, 'a', 'b')
, it will be resolved as users.name,i.e.
select replace(users.name, 'a', 'b') as name from users group by replace(users.name, 'a', 'b')
Why are the changes needed?
Make the sql semantics unchanged when treating identifiers within Group By clause as aliases.
current calcite behavior:
select replace(**name**, 'a', 'b') as **name** from users group by replace(**name**, 'a', 'b')
will be expanded into
select replace(**name**, 'a', 'b') as **name** from users group by replace(**replace(name, 'a', 'b')**, 'a', 'b')
the semantics has been changed.
Does this PR introduce any user-facing change?
No for existing users