Repository navigation
Fix merging filter into JOIN optimization - #84145
Merged
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes a bug in the filter merging into JOIN optimization where equality operands have different types or reference constants. The fix prevents incorrect merging of filters into JOIN conditions when type compatibility issues exist.
Key changes:
- Adds type equality check before pushing equality conditions into JOIN
- Updates merge operation method call for better compatibility
- Adds comprehensive test coverage for various edge cases
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Processors/QueryPlan/Optimizations/mergeFilterIntoJoinCondition.cpp | Core fix: adds type equality check and updates merge method call |
| tests/queries/0_stateless/03572_planner_merge_filter_into_join_bug.sql | Test case for date/datetime type mismatch in JOIN conditions |
| tests/queries/0_stateless/03573_planner_merge_filter_into_join_bug_2.sql | Test case for type casting in JOIN equality conditions |
| tests/queries/0_stateless/03574_analyzer_merge_filter_into_join_bug.sql | Test case for subquery with type mismatches using analyzer |
| tests/queries/0_stateless/03575_analyzer_merge_filter_into_join_bug_2.sql | Test case for correlated subqueries with EXISTS clause |
serxa
approved these changes
Jul 21, 2025
novikd
enabled auto-merge
July 25, 2025 12:40
This was referenced Jul 25, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Jul 25, 2025
novikd
added a commit
that referenced
this pull request
Jul 29, 2025
Backport #84145 to 25.7: Fix merging filter into JOIN optimization
robot-clickhouse
added a commit
that referenced
this pull request
Jul 29, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Jul 29, 2025
clickhouse-gh Bot
added a commit
that referenced
this pull request
Jul 29, 2025
Backport #84145 to 25.6: Fix merging filter into JOIN optimization
novikd
added a commit
that referenced
this pull request
Jul 30, 2025
Backport #84145 to 25.5: Fix merging filter into JOIN optimization
Contributor
|
Hi @novikd @serxa — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix filter merging into JOIN condition in cases when equality operands have different types or they reference constants. Fixes #83432.
Documentation entry for user-facing changes