Skip to content

Fix merging filter into JOIN optimization - #84145

Merged
novikd merged 3 commits into
masterfrom
fix-merge-filter-into-join
Jul 25, 2025
Merged

novikd merged 3 commits into
masterfrom
fix-merge-filter-into-join

Conversation

@novikd

@novikd novikd commented Jul 21, 2025

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [869756a]

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 21, 2025
@serxa serxa self-assigned this Jul 21, 2025
@serxa
serxa requested a review from Copilot July 21, 2025 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@novikd
novikd enabled auto-merge July 25, 2025 12:40
@novikd
novikd added this pull request to the merge queue Jul 25, 2025
Merged via the queue into master with commit 256c5f2 Jul 25, 2025
@novikd
novikd deleted the fix-merge-filter-into-join branch July 25, 2025 13:38
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 25, 2025
@novikd novikd added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 25, 2025
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels 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-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label 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
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @novikd @serxa — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in filter merge into JOIN optimization

7 participants