Skip to content

Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785) - #121375

Merged
Ergus merged 9 commits into
ClickHouse:masterfrom
Ergus:Simpler_112785
Sep 24, 2026
Merged

Ergus merged 9 commits into
ClickHouse:masterfrom
Ergus:Simpler_112785

Conversation

@Ergus

@Ergus Ergus commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Related: #111311
Related: #111329
Closes: #112785

Smaller alternative to #112785: that PR also adds a set-element comparability guard, which belongs to a separate, pre-existing defect: a text index on a FixedString column loses rows for s = 'word1' as well, so an IN-only guard does not fix it.

With transform_null_in = 1 the analyzer renames in/globalIn to nullIn/globalNullIn, and neither MergeTreeIndexConditionText nor MergeTreeConditionBloomFilterText assigned an RPN function for those names, so the index was dropped. With a NULL-free set nullIn selects the same rows as in, so both now accept the renamed spellings and refuse per row when an element is NULL. A Nullable key keeps the wrapper on its set elements at that setting, so the element type is read through it.

This also admits globalIn/globalNotIn on the token bloom filter family, which never reached the index even at transform_null_in = 0.

Follow-up to #111329, which fixed bloom_filter only.

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):

The text, tokenbf_v1, ngrambf_v1 and sparse_grams skip indexes are now used for IN when transform_null_in = 1 and the set contains no NULL. Previously such a query read every granule, and one using force_data_skipping_indices failed with INDEX_NOT_USED.


Workflow [PR]
Sync PR [sync-upstream/pr/121375]

Version info

  • Merged into: 26.10.1.636-master (included in 26.10 and later)
  • Backported to: 26.9.2.38, 26.8.12.51, 26.7.15.51

@Ergus Ergus changed the title Simpler 112785 Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785) Sep 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [91f129d]

Summary: ✅


AI Review

Summary

This PR extends IN analysis for the text, tokenbf_v1, ngrambf_v1, and sparse_grams skip indexes to the null-aware nullIn / globalNullIn spellings produced by transform_null_in = 1, and adds the needed bail-outs for NULL set elements and absent-key map defaults. The implementation and the new stateless coverage match that contract, and I did not find an unresolved correctness or compatibility issue in the current head.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 91f129d.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.50% 79.50% +0.00%

Changed lines: Changed C/C++ lines covered: 65/67 (97.01%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 21, 2026
@Ergus
Ergus marked this pull request as ready for review September 21, 2026 16:50
@Ergus
Ergus requested review from ahmadov and rschu1ze September 21, 2026 16:55
@@ -0,0 +1,71 @@
-- Tests that the `text`, `tokenbf_v1`, `ngrambf_v1` and `sparse_grams` skip indexes prune an `IN`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make the test cases (including the comments) as much similar between the different index types as possible.

@rschu1ze rschu1ze self-assigned this Sep 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 91f129dd6 with master 19254aa9d (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

8 translation units recompiled, 23 s compile time in total, 8 of them have a recent master baseline.

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... label Sep 22, 2026
@Ergus
Ergus added this pull request to the merge queue Sep 24, 2026
Merged via the queue into ClickHouse:master with commit 848069a Sep 24, 2026
172 checks passed
@Ergus
Ergus deleted the Simpler_112785 branch September 24, 2026 20:53
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 24, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 24, 2026
robot-ch-test-poll3 added a commit that referenced this pull request Sep 25, 2026
Cherry pick #121375 to 26.9: Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785)
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
… transform_null_in = 1 (Human alternative for #112785)
robot-clickhouse-ci-2 added a commit that referenced this pull request Sep 25, 2026
Cherry pick #121375 to 26.8: Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785)
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
… transform_null_in = 1 (Human alternative for #112785)
robot-clickhouse-ci-1 added a commit that referenced this pull request Sep 25, 2026
Cherry pick #121375 to 26.7: Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785)
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
… transform_null_in = 1 (Human alternative for #112785)
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 25, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 25, 2026
Backport #121375 to 26.9: Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785)
clickhouse-gh Bot added a commit that referenced this pull request Sep 25, 2026
Backport #121375 to 26.8: Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785)
clickhouse-gh Bot added a commit that referenced this pull request Sep 25, 2026
Backport #121375 to 26.7: Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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 v26.6-must-backport v26.7-must-backport v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants