Skip to content

Backport #121154 to 26.9: Fix wrong results when a predicate applies a NULL-handling function to a Nullable partition key - #130788

Merged
clickhouse-gh[bot] merged 2 commits into
26.9from
backport/26.9/121154
Nov 12, 2026
Merged

clickhouse-gh[bot] merged 2 commits into
26.9from
backport/26.9/121154

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Original pull-request #121154

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

…a NULL-handling function to a `Nullable` partition key
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Nov 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [b48e4ec]

Summary: ✅

@groeneai

Copy link
Copy Markdown
Collaborator

05233_assume_not_null_nullable_partition_key_pruning fails on this branch: its nullIf case (NOT (coalesce(nullIf(c0, 5), 0) = 1) and the EXPLAIN block after it) checks #124041, which is not on 26.9. On the 26.9 tree (clang-22, debug) that row counts 3 rows instead of 4 and the partition step keeps 2 of 4 parts instead of 3, in 3 of 3 runs, with or without the KeyCondition.cpp change of this PR.

Without that case the test passes 50 of 50 with randomized settings, and without the KeyCondition.cpp change it fails 5 of 5 with a wrong count for every other case the change covers.

I cannot push to backport/26.9/121154. A commit that drops that case from the test (16 lines, test files only) is on my fork on top of this PR's head 0cb9f0d52ade, so applying it is a fast-forward:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/fix-26.9-backport-121154
git push origin FETCH_HEAD:backport/26.9/121154

… NULL for it

Port of #124041, a prerequisite of #121154 on this branch: when a link of the monotonic chain
turns a non-NULL bound into NULL, the bound has no position in the `Range` order, so the range
is left unanalyzed instead of compared. Without it the `NOT (coalesce(nullIf(c0, 5), 0) = 1)`
case of `05233_assume_not_null_nullable_partition_key_pruning` still prunes the partition of 5
(4 rows expected, 3 returned), as seen on the 26.9 backport.

#124041 is written against the try/catch chain loop of #117355, which this branch does not have,
so this applies only its check to the branch's loop.

#130788

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim added a commit that referenced this pull request Nov 12, 2026
… NULL for it

Port of #124041, a prerequisite of #121154 on this branch: when a link of the monotonic chain
turns a non-NULL bound into NULL, the bound has no position in the `Range` order, so the range
is left unanalyzed instead of compared. Without it the `NOT (coalesce(nullIf(c0, 5), 0) = 1)`
case of `05233_assume_not_null_nullable_partition_key_pruning` still prunes the partition of 5
(4 rows expected, 3 returned), as seen on the 26.9 backport.

#124041 is written against the try/catch chain loop of #117355, which this branch does not have,
so this applies only its check to the branch's loop.

#130788

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim added a commit that referenced this pull request Nov 12, 2026
… NULL for it

Port of #124041, a prerequisite of #121154 on this branch: when a link of the monotonic chain
turns a non-NULL bound into NULL, the bound has no position in the `Range` order, so the range
is left unanalyzed instead of compared. Without it the `NOT (coalesce(nullIf(c0, 5), 0) = 1)`
case of `05233_assume_not_null_nullable_partition_key_pruning` still prunes the partition of 5
(4 rows expected, 3 returned), as seen on the 26.9 backport.

#124041 is written against the try/catch chain loop of #117355, which this branch does not have,
so this applies only its check to the branch's loop.

#130788

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh
clickhouse-gh Bot merged commit 33f650f into 26.9 Nov 12, 2026
44 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.9/121154 branch November 12, 2026 11:25
leshikus pushed a commit that referenced this pull request Nov 13, 2026
… NULL for it

Port of #124041, a prerequisite of #121154 on this branch: when a link of the monotonic chain
turns a non-NULL bound into NULL, the bound has no position in the `Range` order, so the range
is left unanalyzed instead of compared. Without it the `NOT (coalesce(nullIf(c0, 5), 0) = 1)`
case of `05233_assume_not_null_nullable_partition_key_pruning` still prunes the partition of 5
(4 rows expected, 3 returned), as seen on the 26.9 backport.

#124041 is written against the try/catch chain loop of #117355, which this branch does not have,
so this applies only its check to the branch's loop.

#130788

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
… NULL for it

Port of #124041, a prerequisite of #121154 on this branch: when a link of the monotonic chain
turns a non-NULL bound into NULL, the bound has no position in the `Range` order, so the range
is left unanalyzed instead of compared. Without it the `NOT (coalesce(nullIf(c0, 5), 0) = 1)`
case of `05233_assume_not_null_nullable_partition_key_pruning` still prunes the partition of 5
(4 rows expected, 3 returned), as seen on the 26.9 backport.

#124041 is written against the try/catch chain loop of #117355, which this branch does not have,
so this applies only its check to the branch's loop.

#130788

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
… NULL for it

Port of #124041, a prerequisite of #121154 on this branch: when a link of the monotonic chain
turns a non-NULL bound into NULL, the bound has no position in the `Range` order, so the range
is left unanalyzed instead of compared. Without it the `NOT (coalesce(nullIf(c0, 5), 0) = 1)`
case of `05233_assume_not_null_nullable_partition_key_pruning` still prunes the partition of 5
(4 rows expected, 3 returned), as seen on the 26.9 backport.

#124041 is written against the try/catch chain loop of #117355, which this branch does not have,
so this applies only its check to the branch's loop.

#130788

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants