Skip to content

Fix filter pushdown through legacy JoinStep with join_use_nulls#98337

Merged
alexey-milovidov merged 4 commits intomasterfrom
fix-filter-pushdown-join-use-nulls-legacy
Mar 1, 2026
Merged

Fix filter pushdown through legacy JoinStep with join_use_nulls#98337
alexey-milovidov merged 4 commits intomasterfrom
fix-filter-pushdown-join-use-nulls-legacy

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Summary

  • Fix exception "Unexpected return type from less. Expected Nullable(UInt8). Got UInt8" that occurs when filter pushdown moves a filter expression through a legacy JoinStep with join_use_nulls enabled
  • Restore the type equality check in get_available_columns_for_filter specifically for the legacy JoinStep path, which was inadvertently removed in Support convert OUTER to INNER join optimization with join_use_nulls #95968
  • The JoinStepLogical path is unaffected — it has its own type adjustment mechanism via fix_predicate_for_join_logical_step

Closes #98167

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=ededb4c6063844d24eee5d3023dfe17912307ffa&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

When `join_use_nulls` is enabled, the join output header has Nullable
column types for the outer side. The filter expression (e.g. `k < 10`)
is built with these Nullable types. When filter pushdown moves this
filter to the join input side (where columns are non-nullable), it
causes a type mismatch exception: "Unexpected return type from `less`.
Expected `Nullable(UInt8)`. Got `UInt8`."

Commit 5557b5e removed the type equality check in
`get_available_columns_for_filter` to support `join_use_nulls` with
`JoinStepLogical`, which has `fix_predicate_for_join_logical_step` to
adjust types. But the legacy `JoinStep` has no such adjustment, so
removing the check broke it.

Restore the type check specifically for the legacy `JoinStep` path.

Closes #98167

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=ededb4c6063844d24eee5d3023dfe17912307ffa&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 28, 2026

Workflow [PR], commit [efe536a]

Summary:

Copy link
Copy Markdown
Member Author

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

A straightforward fix - just inhibit the optimization in certain cases for the obsolete legacy JOIN step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r path

The bug only triggers with the old `InterpreterSelectQuery` which always
uses the legacy `JoinStep`. With the new analyzer, even
`query_plan_use_new_logical_join_step = 0` doesn't reproduce it because
the query analysis differs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alexey-milovidov alexey-milovidov self-assigned this Feb 28, 2026
@alexey-milovidov alexey-milovidov added this pull request to the merge queue Mar 1, 2026
Merged via the queue into master with commit 2f74007 Mar 1, 2026
148 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-filter-pushdown-join-use-nulls-legacy branch March 1, 2026 03:03
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 1, 2026
alexey-milovidov added a commit that referenced this pull request Mar 1, 2026
…e-nulls-legacy

Fix filter pushdown through legacy JoinStep with join_use_nulls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

Logical error: Unexpected return type from A. Expected B. Got C. Action: (STID: 1611-3d11)

2 participants