Skip to content

Cherry pick #123778 to 26.8: Keep the set skip index pruning granules that contain NULL - #124411

Closed
robot-ch-test-poll4 wants to merge 3 commits into
backport/26.8/123778from
cherrypick/26.8/123778
Closed

robot-ch-test-poll4 wants to merge 3 commits into
backport/26.8/123778from
cherrypick/26.8/123778

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #123778

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 3 commits October 3, 2026 22:08
`in` and `equals` on a `Nullable` column return `Nullable(UInt8)`, so the
set index evaluates `c IN (803)` to NULL on a stored NULL set element.
#111604 wrapped every nullable bit-wrapped atom in
`ifNull(mask, UNKNOWN_FIELD)` to stop a constant NULL atom from propagating
NULL through `__bitBoolMaskAnd`/`Or` (#103103). That also turned the NULL
of a NULL set element into "can be true", so every granule holding a NULL
passed `IN`/`=` and nothing was pruned (26.6: 32/448 granules, 26.8 and
master: 448/448 on the issue's data).

Map a NULL atom mask to "can be false" only (0b10). The mask connectives
are only and/or/not/indexHint, i.e. Kleene logic, where a value fixed with
a NULL operand stays the same for any definite replacement of it; so a row
that makes the condition TRUE also makes it TRUE with every NULL atom read
as FALSE, and no granule holding a matching row can be pruned. For a plain
atom this is exact (WHERE treats NULL as not passing); under an un-pushed
NOT it stays conservative. The #103103 shapes stay fixed:
`(x AND NULL) OR y` -> `(x AND false) OR y` = `y`. This also matches how
KeyCondition already reads a NULL hint.

Closes #123705

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent-prune

Keep the `set` skip index pruning granules that contain NULL
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Oct 7, 2026
@groeneai

groeneai commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Resolved, on my fork

The conflict is context only. On master, the FALSE_FIELD definition that #123778 adds to src/Storages/MergeTree/MergeTreeIndexSet.cpp sits next to hasMeaningfulFieldExtremes from #120780, which is not on 26.8. I kept FALSE_FIELD after UNKNOWN_FIELD and left hasMeaningfulFieldExtremes out. -X ours would bring that #120780 helper along, so it is not a shortcut here.

I do not have push access here, so the merge is on my fork. It fast-forwards this PR's head:

git fetch https://github.com/groeneai/ClickHouse resolve-26.8-cherrypick-123778
git push origin FETCH_HEAD:refs/heads/cherrypick/26.8/123778

FETCH_HEAD is 2e722735cf57, a git merge --no-ff backport/26.8/123778 on this PR's head 1c8efed9924e. git diff backport/26.8/123778 FETCH_HEAD touches only the 3 files of #123778, with the same added and removed lines as on master.

Checked on a 26.8 debug build of this commit: 05320_set_index_nullable_null_granule_prune passes 50/50 with randomized settings, and so do the other set index tests that run here without S3 or a cluster. With the src/ hunks reverted, 05320 fails: for c IN (5) the index keeps 3 granules instead of 1.

@robot-clickhouse

Copy link
Copy Markdown
Member

Dear @shankar-iyer, @groeneai, this cherry-pick PR has not been updated for 3d0h28m26s. Please resolve the conflicts to backport #123778, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

Dear @shankar-iyer, @groeneai, this cherry-pick PR has not been updated for 7d0h34m22s. Closing automatically. If you still want to backport #123778, please resolve the conflicts and reopen this PR.

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

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants