Fix SELECT * REPLACE behavior in WHERE clause with new analyzer#87630
Merged
antaljanosbenjamin merged 5 commits intoClickHouse:masterfrom Oct 6, 2025
Merged
Conversation
Contributor
|
Workflow [PR], commit [e703049] Summary: ❌
|
f38494e to
a59ff0c
Compare
- Fix column reference issues in WHERE, PREWHERE, ORDER BY, GROUP BY, HAVING, LIMIT BY, WINDOW clauses - Replace original test with comprehensive 17-scenario test suite - Ensure consistent behavior between new and old analyzer
a59ff0c to
e62ac0a
Compare
tests/queries/0_stateless/03631_select_replace_comprehensive.sql
Outdated
Show resolved
Hide resolved
Address review comments from @antaljanosbenjamin: 1. LIMIT BY test enhancement: - Add test data with duplicate values to properly test LIMIT BY grouping - Use expression 'b < 200' to test replaced column in LIMIT BY condition 2. GROUP BY test expansion: - Preserve subquery test (Test 16) - validates replaced values in subquery work with outer GROUP BY - Add direct usage test (Test 17) - validates replaced column can be used directly in GROUP BY clause 3. HAVING test expansion: - Preserve subquery test (Test 18) - validates replaced values in subquery work with outer HAVING - Add direct usage test (Test 19) - validates replaced column can be used directly in HAVING clause Test coverage now includes both subquery patterns (important for nested query validation) and direct usage patterns (requested by reviewer) for GROUP BY and HAVING clauses.
Member
antaljanosbenjamin
left a comment
There was a problem hiding this comment.
One question only to be sure we are not making a mistake here. Apart from that, it looks good.
tests/queries/0_stateless/03631_select_replace_comprehensive.reference
Outdated
Show resolved
Hide resolved
antaljanosbenjamin
approved these changes
Oct 6, 2025
Member
|
Failed test is caused by #87655. Merging PR. |
Merged
via the queue into
ClickHouse:master
with commit Oct 6, 2025
bfc360e
121 of 123 checks passed
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.
Fix SELECT * REPLACE behavior in WHERE clause with new analyzer
This commit fixes issue #85313 where SELECT * REPLACE with WHERE clause on the same column returned incorrect results with the new analyzer. For example:
SELECT * REPLACE(a + 10 AS b) FROM test WHERE b = 11 was returning empty results instead of matching rows where the replaced expression equals 11.
The root cause was that the new analyzer processes SELECT * REPLACE and WHERE clause sequentially, causing WHERE conditions to see original column values instead of replaced values. The old analyzer processes both together correctly.
The fix captures REPLACE transformer mappings during resolveMatcher processing and immediately applies inline identifier replacement to WHERE and HAVING clauses using lambda functions.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):