Fix OLAP window function SQL generation when preceded by groupBy with computed expressions#4362
Closed
peledni wants to merge 1 commit intofinos:masterfrom
Closed
Conversation
|
|
f0d8d34 to
95eb6c0
Compare
gs-ssh16
previously approved these changes
Jan 23, 2026
Test Results 1 057 files - 18 1 057 suites - 18 2h 54m 53s ⏱️ - 1h 0m 27s Results for commit 0022ca3. ± Comparison against base commit 4955997. ♻️ This comment has been updated with latest results. |
… computed expressions When using groupBy with computed expressions (e.g., monthNumber(), year()) followed by olapGroupBy, the generated SQL was invalid because the PARTITION BY clause referenced the raw computed expression instead of the column alias from the GROUP BY. This caused "Column must be in GROUP BY list" errors in databases like Postgres. The fix extends the existing subselect isolation logic in processTdsWindowColumn to also wrap GROUP BY queries in a subselect when the window's partition/order columns reference computed expressions (non-TableAliasColumn elements). Simple column references are left unchanged to avoid unnecessary nesting.
95eb6c0 to
0022ca3
Compare
Member
|
This PR is stale because it has been open for 30 days with no activity. Please remove stale label or add any comment to keep this open. Otherwise this will be closed in 5 days. |
Member
|
This PR was closed because it has been inactive for 35 days. Please re-open if this PR is still relevant. |
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
groupBywith computed expressions (e.g.,monthNumber(),year()) followed byolapGroupByPARTITION BYclause was referencing raw expressions instead of column aliases, causing "Column must be in GROUP BY list" errorsProblem
When using
groupBywith computed expressions followed byolapGroupBy, the generated SQL was invalid:Before (invalid SQL):
After (valid SQL):
Test plan
testGroupByWithComputedExpressionFollowedByOlapGroupBytestExecutionPlanGenerationto reflect new expected SQL structure