Skip to content

Use text and token skip indexes for IN with transform_null_in = 1 - #112785

Closed
groeneai wants to merge 34 commits into
ClickHouse:masterfrom
groeneai:fix-text-family-transform-null-in-20260731
Closed

groeneai wants to merge 34 commits into
ClickHouse:masterfrom
groeneai:fix-text-family-transform-null-in-20260731

Conversation

@groeneai

@groeneai groeneai commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #111311
Related: #111329

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

Makes the text, tokenbf_v1, ngrambf_v1 and sparse_grams skip indexes apply to IN when transform_null_in = 1 and the set contains no NULL, so a query no longer loses index pruning just because that setting is enabled. Previously such a query read every granule, and one using force_data_skipping_indices failed with INDEX_NOT_USED. A set that does contain NULL keeps the original predicate, since nullIn also matches the column's NULL rows.

Description

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

With transform_null_in = 1 the analyzer rewrites x IN (...) to nullIn(x, ...) and globalIn to globalNullIn. Two skip-index condition classes decide on the function name. MergeTreeIndexConditionText accepted only in/globalIn, so the atom stayed unknown and the index was dropped entirely. MergeTreeConditionBloomFilterText (shared by tokenbf_v1, ngrambf_v1 and sparse_grams) did admit the new names, prepared the bloom filters and then discarded them, because its body assigned an RPN function only for notIn and in.

Adding the names alone would give wrong results. Set elements are materialized from the left-hand key type, and Set::getElementTypes strips Nullable only when transform_null_in is off, so a Nullable key keeps the wrapper even for a NULL-free set. Measured on a text index over Nullable(String), x IN ('word5', NULL) returns 1 row at transform_null_in = 0 and 11 at 1; pruning the second case would drop granules holding real results. So each site now tolerates a Nullable wrapper in its existing type rule and refuses per row via isNullAt at the tokenized position only, which keeps NULL in an unindexed tuple component prunable.

Two further changes are disclosed rather than advertised. globalIn never pruned on the token bloom filter family even at transform_null_in = 0; the same one-line branch fixes that, so transform_null_in = 0 is not untouched. And a predicate that now prunes every granule no longer reaches an execution-time error it previously reached. That is a pre-existing property of pruning, observable on the primary key alone, and it already applied to in on these indexes; the effect here is that nullIn now behaves like the in it mirrors, where master has the two spellings disagree.

The added bound check mirrors the text sibling and is not reachable today.

Validation

Both directions, from one worktree with only the two source files reverted:

carrier before, transform_null_in = 1 after
text String / LowCardinality(String) / FixedString(12) index dropped Granules: 2/250
text Nullable(String) / LowCardinality(Nullable(String)), NULL-free index dropped prunes
text tuple set, incl. indexed component at position 1 and a Nullable indexed component index dropped prunes
text map element value, JSON subcolumn via ::String index dropped prunes
tokenbf_v1 String / LowCardinality(String) / tuple set 250/250 2/250
ngrambf_v1 String / LowCardinality(String), sparse_grams String 250/250 29/250
force_data_skipping_indices, all four INDEX_NOT_USED returns rows

Row counts match between the two transform_null_in arms in every cell, so the test asserts correctness as well as pruning. Unchanged and verified: a NULL-containing set still does not prune and still returns 11 rows, NOT IN still never prunes, the empty-string and tokenizes-to-nothing bail-outs still bail out, and mixed-type tuples still prune on text and still do not on the token bloom filter family.

Six mutation arms, each reddening a specific cell set: removing the isNullAt refusal makes the NULL-set query fail with NOT_IMPLEMENTED; removing only the Nullable tolerance reddens exactly the five Nullable cells while the plain String cells pass; reverting either site reddens exactly that site's cells; making the bound check too eager reddens every token bloom filter cell.

50 tag-free randomized runs at --jobs 8: 50 OK. Regression sweep over 255 tests, identical selection in both arms with the ran-test sets asserted equal: 0 new failures, 1 improvement (the new test).


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

groeneai and others added 2 commits July 31, 2026 03:16
…ull_in

With transform_null_in = 1 the analyzer rewrites `x IN (...)` to `nullIn(x, ...)` (and
`globalIn` to `globalNullIn`). Two skip index condition classes gate on the function name and
never assigned a pruning function for the new names, so the atom stayed unknown and the index
was dropped: `text`, and the shared class behind `tokenbf_v1`, `ngrambf_v1` and `sparse_grams`.
The result was not only lost pruning; `force_data_skipping_indices` went from working to
`Code 277 INDEX_NOT_USED` purely by flipping the session setting.

For a set without NULL, `nullIn` selects exactly the rows `in` selects, so pruning is sound.
For a set containing NULL it also matches the column's NULL rows, which token and bloom filter
hashing cannot represent, so those sets are refused: pruning them would drop granules holding
real result rows. This is why the fix cannot mirror `KeyCondition`, which maps `nullIn` with no
such guard because `Set::checkInRange` represents the NULL element natively.

`Set::getElementTypes` strips Nullable only when the setting is off, so at transform_null_in = 1
a Nullable key keeps the wrapper on its set elements even when no element is NULL. Both helpers
therefore look through the wrapper for the type check and refuse per row on the null map at the
tokenized position, leaving the existing element read unchanged. Which positions are type
checked is deliberately untouched, so a mixed type tuple keeps not using the token bloom
indexes.

Two smaller changes ride along in the same statements. `globalIn` was missing from the token
bloom name test, so it never pruned there even with the setting off. And the element read in
that helper indexes set element columns with a left hand argument position without a bound
check; the text sibling has that check, so it is mirrored here.

Verified against a pristine master build: every carrier goes from no pruning to pruning at
transform_null_in = 1, a NULL containing set keeps returning its NULL rows unpruned, and
Code 6 CANNOT_PARSE_TEXT still fires for a type incompatible set.
…oken indexes

Covers all four affected index types (text, tokenbf_v1, ngrambf_v1,
sparse_grams) across the wrapper matrix, tuple/map/JSON carriers, the
force_data_skipping_indices regression, and the must-not-change cases: a
NULL-containing set still keeps the original predicate and still returns the
NULL rows, NOT IN still never prunes, the existing empty-string and
tokenizes-to-nothing bail-outs still bail out, and a mixed-type tuple still
prunes on text while still not pruning on the token bloom filter family.

Two cells record behaviour the earlier analysis had backwards, each measured on
a pristine master build:

FixedString(12) on a text index is a real carrier, not a non-carrier. It prunes
2/250 at transform_null_in = 0, loses that at 1, and the fix restores it, so it
is asserted as a gain rather than as unchanged.

A type-incompatible set raises CANNOT_PARSE_TEXT only at transform_null_in = 1.
At 0 the query returns 0 rows with no error. That asymmetry comes from the set
conversion, not from index analysis: it reproduces identically with no skip
index at all and with a set index, on unmodified master. The tnin=1 rows stay
serverError cells; the tnin=0 rows assert the value.

The test carries no tags, and passes 50 tag-free randomized runs at --jobs 8.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

Before opening this PR I ran an independent review pass plus a second-model review of the diff, and adjudicated every finding against the code. Recording it here so a reviewer can see what was already checked and what was deliberately not changed.

8 approach-review rounds on the design (14 findings, 13 accepted, 1 rejected) and 1 code-review round on the result (2 findings). The design rounds are what removed a blanket single-column guard that would have made tuple sets unreachable, found sparse_grams from the index registry rather than from the report, and replaced an ineffective hasNull()-style guard with the per-row isNullAt refusal that ships. One round retracted a false claim of my own about pruning and error masking; the disclosure in the description above is the corrected version.

❌ Rejected, with evidence

Validate complete set arity and type compatibility before mapping the new spellings, and require NUMBER_OF_COLUMNS_DOESNT_MATCH in the absent-token test. Two halves, both rejected after reading the code.

Arity. This would be a new hazard only if mapping widened the set of shapes prunable before Set::checkColumnsNumber. It does not. At the merge base MergeTreeIndexConditionText::tryPrepareSetForTextSearch already contains exactly two column-count tests, the tuple unpack and *set_key_position >= columns.size(), and no logical-arity check; MergeTreeConditionBloomFilterText::tryPrepareSetBloomFilter has none. Neither type-admission rule was weakened: the token bloom filter test is byte-identical to the merge base, and the text test changed only its operand, so that it looks through a Nullable wrapper. At transform_null_in = 0, where in has always mapped, master already prunes the arity-invalid shape through this identical code. Set::checkColumnsNumber is reached only from Set::execute, which runs per surviving block, so pruning every granule skips it. That is a property of pruning rather than of these helpers: measured with no skip index at all, the primary key alone masks throwIf, division by zero and a parse failure on granules it prunes. A guard in these two helpers cannot make that consistent while minmax and the primary key keep masking the same errors, and the specific failing shape is a column-count mismatch whose types agree, so the proposed type comparison cannot detect it. The equivalent clause was in the first design revision and was rejected there for making tuple sets unreachable.

Requiring the exception in the absent-token cells would encode the opposite of the invariant this change establishes. Those cells assert that the two transform_null_in arms are equal, which is the point: nullIn now behaves like the in it mirrors. The present-token shape, where a granule survives and the filter executes, is pinned as serverError NUMBER_OF_COLUMNS_DOESNT_MATCH on both families at both settings.

Cross-type String against FixedString(N) hiding TOO_LARGE_STRING_SIZE. Unreachable. Set elements are converted to the left-hand key type at set build time, upstream of both helpers: makeExplicitSet passes the left argument type into getSetElementsForConstantValue, which converts each element through convertFieldToTypeCheckEnum against that type, and Set::setHeader takes set_elements_types from the already-converted header. By the time either type test runs, a String literal against a FixedString(N) key is already FixedString(N), or the conversion has thrown. The throw in toFixedString lives on that upstream path, not behind any pruning decision this diff influences.

💡 Noted, not changed

Comment style. Four added comment lines write getDataAt() and isNullable() where the repository guidance asks for getDataAt and isNullable, and Set::getElementTypes, MergeTreeIndexConditionText::tryPrepareSetForTextSearch, tuple_index, columns and LowCardinality appear without inline code formatting. Correct and worth fixing; it is comment prose with no effect on generated code, so it is listed rather than folded into a separate round. Happy to push it if preferred.

The added bound check is not reachable today. Its four companion test rows assert upstream rejection, so they pass with or without it. It mirrors the identical test the text sibling already had, and a mutation making it too eager reddens every token bloom filter cell, so it is not over-broad. Shipping the two sites asymmetrically seemed worse than a guard that is currently defensive.

Merge order

My open #110024 touches the adjacent line. git merge-tree reports a content conflict in MergeTreeIndexConditionText.cpp, but the two changes are complementary rather than alternatives: that PR's helper fires only when the right-hand side is a constant boolean and otherwise returns false, so a bare x nullIn ('a','b') still falls through to the gate widened here, and it does not touch the token bloom filter site at all. Whichever merges second should keep both, its wrapper call above this widened gate. There is no test-number collision.

Session id: cron:clickhouse-review-slot-48:20260731-175500

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. One command, no randomization and no fuzzer: clickhouse local --queries-file tests/queries/0_stateless/04660_text_token_index_transform_null_in.sql. Minimal form is a text index over 1000 rows with index_granularity = 4 and EXPLAIN indexes = 1 SELECT count() FROM t WHERE x IN ('word5','word500') SETTINGS transform_null_in = 1. Every fixture uses ORDER BY tuple() so primary-key pruning cannot contaminate the reading.
b Root cause explained? Yes. transform_null_in = 1 makes the analyzer rewrite x IN (...) to nullIn(x, ...) and globalIn to globalNullIn. MergeTreeIndexConditionText gated on function_name == "in" || function_name == "globalIn", so the atom stayed FUNCTION_UNKNOWN, alwaysUnknownOrTrue dropped the index, and the Skip section vanished from the plan. MergeTreeConditionBloomFilterText admitted the new names through functionIsInOrGlobalInOperator, prepared the bloom filters successfully, then discarded them because its body assigned an RPN function only for notIn and in.
c Fix matches root cause? Yes. It maps the names the rewrite actually produces, at the two gates that reject them, and refuses exactly the case that would be unsound. Not a widened bound, not a tag, not a data-size reduction, and not a defensive check masking an upstream bug.
d Test intent preserved / new tests added? New test 04660_text_token_index_transform_null_in, 113 assertions across 16 gain cells plus must-not-change, error, bail-out and non-carrier cells. No existing test was weakened. 04063_text_index_in_tuple (whose four serverError rows pin the tuple support this must not regress), 01681_bloom_filter_nullable_column (which pins NUMBER_OF_COLUMNS_DOESNT_MATCH at transform_null_in = 1) and 04303_key_condition_ifnull_coalesce_boolean are MATCH/MATCH on both arms.
e Both directions demonstrated? Yes, from one worktree with only the two source files reverted, both Build IDs asserted equal to SELECT lower(buildId()). Pre-fix f5d98aee: RC=21, aborts with Code: 277 INDEX_NOT_USED, 95 of 113 reference lines differ, all 16 gain cells read 0. Fix f94f3f54: RC=0, output byte-identical to the reference, empty stderr.
f Fix is general across code paths? Both condition classes are fixed, not only the reported one. The third and fourth affected index types (ngrambf_v1, sparse_grams) were derived from the index registry rather than from the report. Fixed at the decision site, not guarded at a symptom site. Non-carriers proven by construction: the virtual-column consumer of the search-query name is unreachable because the IN path hardcodes TextIndexDirectReadMode::None; MergeTreeReaderTextIndex compares only against hasAnyTokens/hasAllTokens; the TextIndexAnalyzer logical error uses the name only in its message; both RPN evaluators are pure OR-across-elements, i.e. exactly in semantics, so there is no evaluation-side change; alwaysUnknownOrTrue already listed both functions. Storage-agnostic, so no Replicated or Shared asymmetry, and nothing is persisted.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes, and the matrix is asserted in the test: String, LowCardinality(String), Nullable(String), LowCardinality(Nullable(String)), FixedString(12), tuple sets (including the indexed component at position 1, a Nullable indexed component, and a Nullable unindexed component), map element values, JSON subcolumns, and Array(String). Boundaries: empty-string element, element tokenizing to nothing, NULL in the set, NULL at a tuple position, absent token, type-incompatible set, arity-invalid right-hand side, shorter right-hand side. Nullable on the token bloom filter family is unconstructible (Code 36 at CREATE, including via a toNullable(x) index expression), so no cell claims it.
h Backward compatible? Yes, nothing to migrate. No setting default changes, so no SettingsChangesHistory.cpp entry; no new setting, no experimental gate, no format, serialization, protocol or ABI change. This restores an optimization that already applies at transform_null_in = 0, under a strictly narrower predicate. Three behaviour deltas, all disclosed in the description: nullIn/globalNullIn prune when provably equivalent at transform_null_in = 1; globalIn prunes on the token bloom filter family at both settings; and, as a consequence, a predicate pruning every granule no longer reaches an execution-time error, which is a pre-existing property of pruning that already applied to in on these indexes.
i Invariants and contracts preserved? The invariant is that an atom mapped to a token pruning function must select exactly the rows the original predicate selects. The refusal is evaluated at the tokenized position only, uniformly for scalar and tuple sets, so it needs no arity precondition; Set::hasNull() could not have served, being false by definition for any multi-column set. Nullability is detected with isColumnNullableOrLowCardinalityNullable, since isNullable() is false for LowCardinality(Nullable), so getDataAt is never reached on a NULL row. On refusal the text site clears its partially-built query list before returning false, matching the two existing bail-outs in the same loop. Neither site's rule about which positions are examined changed, so a mixed-type tuple still does not use the token bloom filter family. Nothing is persisted and no lock or concurrency contract is touched.

Validation beyond the table: six mutation arms, each reddening a specific cell set and nothing else (removing the isNullAt refusal makes the NULL-set query fail with NOT_IMPLEMENTED; removing only the Nullable tolerance reddens exactly the five Nullable cells while the plain String cells pass; reverting either site reddens exactly that site's cells; making the added bound check too eager reddens every token bloom filter cell). After the mutations the restore relinked bit-identically with both source checksums restored, so no mutation residue ships. 50 tag-free randomized runs at --jobs 8: 50 OK, 0 FAIL. Regression sweep over 255 tests with the identical selection in both arms and the ran-test sets asserted equal: 0 new failures, 1 improvement.

Session id: cron:clickhouse-review-slot-48:20260731-175500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ @Ergus, could you review this? With transform_null_in = 1 the analyzer rewrites x IN (...) to nullIn, and neither the text condition nor the shared tokenbf_v1/ngrambf_v1/sparse_grams one assigned an RPN function for that name, so those indexes silently stopped pruning and force_data_skipping_indices started failing with INDEX_NOT_USED. The names alone would be unsound, since a Nullable key keeps the wrapper on its set elements at that setting, so each site also refuses per row at the tokenized position.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d210a97]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

This PR extends text, tokenbf_v1, ngrambf_v1, and sparse_grams skip-index handling to the transform_null_in = 1 spellings and adds representation guards for IN set elements. The main fix looks coherent, but the current comparability guard still regresses an existing IN pruning path on wrapped string carriers with safe, type-blind preprocessors, so I do not think it is ready to merge as-is.

Missing context / blind spots
  • ⚠️ The currently available PR CI report only exposed Build profile diff; I did not have a fresh full Praktika matrix to confirm the latest stateless/integration coverage against the current head.
Findings

⚠️ Majors

  • [src/Storages/MergeTree/MergeTreeIndexTextSetHelper.cpp:56] dismissed by author -- discussion The new comparability allowlist still rejects wrapped string carriers for any preprocessor that is not exact ASCII lower/upper or direct CAST(<index column>, ...). That drops already-working IN pruning for safe, type-blind preprocessors such as hex(val) on Nullable(String) / LowCardinality(String) carriers at transform_null_in = 0, and it also turns force_data_skipping_indices into INDEX_NOT_USED for queries that master prunes today. I agree that some wrapped-carrier preprocessors are unsafe, but this guard is still too coarse: it fixes the wrong-results class by regressing a narrower, previously supported IN contract instead of distinguishing safe preprocessors from unsafe ones.
    Suggested fix: make comparability depend on the preprocessor's actual normalization behavior rather than a tiny syntax allowlist, or at minimum add focused regression coverage for a safe wrapped-carrier case such as preprocessor = hex(val) and keep that path green.
Tests
  • The new regression file covers the nullIn/globalNullIn spellings and the NULL-containing-set refusals, but it still does not pin IN on wrapped string carriers with a safe non-folding preprocessor. That is the coverage hole that allowed the pruning regression above to survive.
Final Verdict

⚠️ Changes requested

LLVM Coverage Report

Measured on commit d210a97.

Metric Baseline Current Δ
Lines 88.00% 88.00% +0.00%
Functions 91.80% 91.70% -0.10%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 111/130 (85.38%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 1, 2026
Comment on lines 810 to +836
@@ -822,10 +831,22 @@ bool MergeTreeConditionBloomFilterText::tryPrepareSetBloomFilter(
key_position.push_back(elem.key_index);

size_t tuple_idx = elem.tuple_index;
/// tuple_index counts left-hand arguments while columns are the set elements. Mirrors the
/// bound check in MergeTreeIndexConditionText::tryPrepareSetForTextSearch.
if (tuple_idx >= columns.size())

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.

tryPrepareSetBloomFilter still assumes the RHS set is already split into one column per tuple element, but the text sibling has to unpack ColumnTuple explicitly for IN (SELECT tuple(...)) (04063_text_index_in_tuple.sql pins that shape). On this path, a RHS like (id, str) IN (SELECT tuple(id, 'word5') FROM ...) can stay packed as a single Tuple(...) set column, so the new removeNullable(...)->getTypeId() check rejects it immediately, and the later tuple_idx >= columns.size() guard would also reject an indexed component at position 1. That leaves tokenbf_v1 / ngrambf_v1 / sparse_grams still falling back to FUNCTION_UNKNOWN for this valid IN carrier under transform_null_in = 1, so force_data_skipping_indices can still fail there.

Please mirror the tuple unpack that MergeTreeIndexConditionText::tryPrepareSetForTextSearch does before the type and bounds checks, and add a regression that uses SELECT tuple(...) on the RHS for one of the token-bloom indexes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The sibling asymmetry is real: MergeTreeIndexConditionText.cpp:1698-1701 unpacks a packed ColumnTuple, tryPrepareSetBloomFilter does not. But it is not a transform_null_in gap and not something this PR's changes introduced, so I am not mirroring the unpack here.

Measured on tokenbf_v1, all-string LHS and RHS so the mixed-type rule cannot confound the reading (ORDER BY tuple(), index_granularity = 4, 1000 rows, force_data_skipping_indices = 'idx_str'):

build RHS transform_null_in = 0 transform_null_in = 1
master 7a551db1 SELECT tuple(a, 'word5') INDEX_NOT_USED INDEX_NOT_USED
master 7a551db1 SELECT a, 'word5' prunes INDEX_NOT_USED (the bug this PR fixes)
this PR f94f3f54 SELECT tuple(a, 'word5') INDEX_NOT_USED INDEX_NOT_USED
this PR f94f3f54 SELECT a, 'word5' prunes prunes

The packed form fails on unmodified master at transform_null_in = 0, where in has always mapped, so "still ... under transform_null_in = 1" does not hold. The PR changes exactly one cell.

On the two specific mechanisms:

  • The type check is what rejects a packed set, but its admission is unchanged. removeNullable only widens: merge-base had prepared_set_data_type->getTypeId(), this PR has removeNullable(prepared_set_data_type)->getTypeId() against the same String/FixedString pair, and removeNullable returns its argument for a non-Nullable type (DataTypeNullable.cpp:239-244). A Tuple(...) was rejected before and is rejected now. In your (id, str) example it never reaches that question anyway: the loop iterates getDataTypes() (:810), which is the set's key types filled per key column in Set::setHeader (Set.cpp:148-166), so it rejects on the UInt64 entry. getSetElements() is only read afterwards at :825.
  • The bound check does not reject an indexed component at position 1. It is tuple_idx >= columns.size(), and columns.size() is 2 for a valid 2-column set, so tuple_idx == 1 passes. 04660:158-160 already pins that shape on tokenbf_v1 (index on tuple position 1, prunes at both settings, rows equal), and 04660:275-284 covers it with a Nullable unindexed component.

The reason I am not relaxing this: the token-bloom type loop is an all-components rule, while text's is per-position. That asymmetry predates this PR and is deliberately preserved, because relaxing it would newly prune mixed-type tuples on the token-bloom family at transform_null_in = 0 as well, which is a behaviour change unrelated to this fix. It is pinned as intended behaviour by 04660:293-296 (mixed tuple tokenbf_v1 / ngrambf_v1 not pruned, both settings) against 04660:291-292 asserting text does prune the same shape. Implementing the unpack as requested would redden those four assertions.

Widening the token-bloom condition to per-position type checks is a reasonable follow-up on its own merits, and it would want its own before/after numbers at both transform_null_in values. I would rather not fold it in here, since it changes pruning at transform_null_in = 0 on a path this PR otherwise leaves alone.

I also checked the LowCardinality question, and there is no hole: Set::setHeader applies recursiveRemoveLowCardinality to the element types and converts LC key columns to full (Set.cpp:156-165), so the wrapper never reaches either type test, and the per-row refusal uses isColumnNullableOrLowCardinalityNullable. LowCardinality(String) prunes on text and tokenbf_v1 at both settings; LowCardinality(Nullable(String)) prunes for a null-free set, and for IN ('word5', NULL) it correctly refuses to prune and returns the NULL rows.

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 40ec117

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

CI is terminal on this head (174 check-runs, 0 queued or in progress, Config Workflow and Finish Workflow green). One failure:

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3) / 04660_text_token_index_transform_null_in PR-caused, and a defect in my own new test rather than in the change under test. The pruning oracle is ... WHERE explain LIKE '%Granules: %/%' AND toUInt64(extract(explain, 'Granules: (\d+)/')) < ..., which assumes AND short-circuits. It does not: the runner reports Code: 32 ... Cannot parse UInt64 from String, because value is too short: while executing 'FUNCTION toUInt64(extract(explain, 'Granules: (\d+)/'))', so the cast ran on EXPLAIN rows that carry no granule count. Deterministic here (3 of 3 reruns), first assertion of the file, and CIDB has 1 row for this test in 30 days: this head only PR-caused -> fixed in this PR

Session id: cron:our-pr-ci-monitor:20260801-203000

The pruning assertions read

  WHERE explain LIKE '%Granules: %/%'
    AND toUInt64(extract(explain, 'Granules: (\d+)/')) < ...

which assumes the LIKE conjunct gates the cast. It does not: WHERE conjuncts
are evaluated over the whole column, so the cast was also applied to the
EXPLAIN rows that carry no `Granules:` substring, where extract returns an
empty string and toUInt64 throws

  Code: 32. ATTEMPT_TO_READ_AFTER_EOF: Cannot parse UInt64 from String,
  because value is too short

The test aborted on its first assertion. It reddened in the amd_llvm_coverage
old-analyzer lane, whose EXPLAIN row set differs from the lanes the test was
developed against; the dependence is on plan-text shape, not on randomized
settings.

Switching both casts to toUInt64OrZero makes them total. Zero is safe for the
read < total comparison: a row without a granule pair reads 0 < 0, which is
false, so only real granule rows can satisfy it, and the magic-constant-free
read < total form the plan pinned is preserved. Applied to all 61 assertions,
since every one of them was exposed.

Verified in both analyzer modes against the fixed binary (reference
byte-identical) and, for non-vacuity, against a binary built from the
merge-base of the two changed source files: there the repaired oracle still
aborts with Code 277 INDEX_NOT_USED, 95 reference lines differ, and all 16
gain cells read 0 under the old analyzer as well as the new one.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed the 04660 pruning oracle (PR-caused CI failure on 40ec1175)

Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3) failed 3/3 reruns on my own new test, aborting on its first assertion:

Code: 32. DB::Exception: Attempt to read after eof: Cannot parse UInt64 from String,
because value is too short: while executing 'FUNCTION toUInt64(extract(explain, 'Granules: (\d+)/'))'

Root cause. The assertions were written as

WHERE explain LIKE '%Granules: %/%' AND toUInt64(extract(explain, 'Granules: (\d+)/')) < ...

which assumes the LIKE conjunct gates the cast. It does not: WHERE conjuncts are evaluated over the whole column, so the cast also saw the EXPLAIN rows with no Granules: substring, where extract returns ''. That exposed all 61 assertions, not just the first. It surfaced in the old-analyzer lane because its EXPLAIN row set differs from the lanes I developed against; the dependence is on plan-text shape, not on randomized settings.

Fix (759fbdba): both casts become toUInt64OrZero, applied to all 61 assertions. Zero is safe for the read < total comparison, since a row with no granule pair reads 0 < 0 = false, so only real granule rows can satisfy it. The magic-constant-free read < total form and the paired transform_null_in = 0 control rows are unchanged.

Verification. Both analyzer modes now produce a byte-identical reference against the fixed binary. For non-vacuity I rebuilt from the merge-base of the two changed source files and re-ran the repaired oracle: it still aborts with Code: 277 INDEX_NOT_USED, 95 reference lines differ, and all 16 gain cells read 0 under the old analyzer as well as the new one, so OrZero did not make the assertions vacuously true.

I also checked the alternative of wrapping the filter in a nested subquery first: under the old analyzer the subquery is flattened and it still throws Code: 32, so it is not a viable form here.

Only the test file changed in this round; src/ is untouched.

Session id: cron:clickhouse-maint-slot-16:20260801-204501

@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 37/39 (94.87%) · Uncovered code

Full report · Diff report

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 759fbdb

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_tsan) / Logical error: Can't determine table for parallel replicas (STID 3634-3276) pre-existing trunk assert in parallel-replicas table selection, not caused by this diff (this PR touches text/token skip-index IN analysis with transform_null_in = 1, not parallel-replicas table selection) a fix task is created (investigating at full effort - fixing-PR link to follow here)

Gate: 174 check-runs, 0 queued/in_progress; Config Workflow success, Finish Workflow success (02:30:36Z); 155 success / 18 skipped / 1 failure.

Session id: cron:our-pr-ci-monitor:20260802-030000

@@ -0,0 +1,326 @@
-- Under transform_null_in = 1 the analyzer rewrites `x IN (...)` to `nullIn(x, ...)` (and

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.

@groeneai Simplify this test radically. Avoid all slop comments. Select a couple of representative test cases for each index type.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 576837d.

The test is 41 lines instead of 326, with 3 tables instead of 21 and no comments except the two that state why a case exists. Two cases per index type (scalar IN and GLOBAL IN), plus the NULL-in-set refusal. It asserts the Granules: read/total line directly, so the reference shows the actual ratios and there is no regex or cast any more.

I checked each remaining assertion is load-bearing rather than just shorter: on a binary built from the pre-fix sources all six pruning rows fail, neutering the two per-row isNullAt guards fails the NULL-in-set row, reverting the Nullable look-through fails the text and tokenbf_v1 rows, and removing the globalIn name fails its row. Same output under both analyzers.

Dropped the LowCardinality, FixedString, map, JSON, sparse_grams, tuple-position and mixed-type-tuple cases. They shared a code path with a case I kept, and sparse_grams uses the same condition class as tokenbf_v1 with a different tokenizer.

auto rhs_argument = function.getArgumentAt(1);

if ((function_name == "in" || function_name == "globalIn")
/// `nullIn`/`globalNullIn` are what `in`/`globalIn` become under `transform_null_in = 1`.

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.

@groeneai Shorten the comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 576837d. Shortened this one to two lines, and did the same to the other seven comment blocks in the diff since they had the same problem. The reasoning about Set::getElementTypes and which tuple positions each family checks is in the commit messages now.

@rschu1ze

Copy link
Copy Markdown
Member

@Ergus Really not urgent but do you like to check this one? It adds special handling for transform_null_in = 1.

Per review: reduce the test to a couple of representative cases per index
type and shorten the source comments.

The test now asserts index usage with force_data_skipping_indices instead of
parsing granule counts out of EXPLAIN indexes = 1 output. That removes 61
regex assertions and the toUInt64OrZero guard they needed, because the
setting turns "the index was not used" directly into INDEX_NOT_USED. The
oracle is unchanged in strength: every one of the six remaining pruning
assertions fails on a binary built without the fix (Code 277), and the
NULL-in-set refusal fails when the per-row isNullAt guards are neutered
(Code 48, getDataAt on a NULL element). Verified in both analyzers, and
three concurrent copies in separate databases agree, so the test stays
parallel-safe.

The comments kept only the local invariant at each site. The reasoning about
Set::getElementTypes stripping Nullable only when transform_null_in is off,
and about which tuple positions each family checks, is recorded here rather
than in the source.
Second-model review made two points that measurement confirmed.

force_data_skipping_indices only checks that the index landed in the useful
list (MergeTreeDataSelectExecutor.cpp:956-976), so it proves the condition was
admitted, not that granules were skipped. The assertions now print the
Granules: read/total line itself, so the reference records the actual ratios
(2/250 for text and tokenbf_v1, 29/250 for ngrambf_v1, whose bloom filter is
less selective). No regex and no cast, so the AND short-circuit hazard that
the previous round fixed cannot come back.

Every global query used transform_null_in = 1, so nothing covered the
globalIn name this PR also adds to the token-bloom mapping. That name was
admitted but never assigned an RPN function, so GLOBAL IN did not prune there
even at transform_null_in = 0. Removing only that one name left the test
green; it now has its own row.

Mutation matrix, each arm Build-ID asserted against buildId(): pre-fix kills
the six pruning rows; neutering the two per-row isNullAt guards kills the
NULL-in-set row (Code 48 instead of 277); reverting the Nullable look-through
kills the text and tokenbf_v1 rows; removing globalIn kills the new row.
Both analyzers agree and three concurrent copies in separate databases agree.
The granule counts show that pruning happened, not that it kept the right
granules. Add one row-count comparison per index family between
transform_null_in = 0 and 1.

The oracle discriminates: the underlying counts are 2, not 0, and the same
comparison on a set containing NULL returns 0 because those arms legitimately
differ (1 versus 11 rows).
Review nit: write isNullable rather than isNullable(), and mark tuple_index, columns, Nullable and LowCardinality as code.
The assertions printed trim(explain), which strips ASCII whitespace but not the
tree-drawing prefix that EXPLAIN puts in front of a nested node. Under parallel
replicas the plan gains a Union above the aggregation, so ReadFromMergeTree is no
longer the last top-level child and its detail lines carry a leading U+2502 box
character. trim leaves that byte in, so every granule row printed
"│               Granules: 2/250" and the test failed on
"Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)"
while passing everywhere else.

The granule numbers themselves were identical on both lanes, so extracting the
"Granules: read/total" substring keeps the reference file byte-for-byte and drops
the dependence on how deep the node sits in the plan. extract returns an empty
string rather than throwing when a row does not match, so it stays total over the
whole column the way the previous round's toUInt64OrZero repair had to.

Verified against a pre-fix binary built from the merge-base copies of both
changed sources: all seven granule rows disappear there, on the plain lane and
the parallel-replicas lane alike, so the assertions are not vacuously satisfied.
The three mutation arms from the previous round (both isNullAt guards neutered,
the Nullable look-through reverted, the globalIn name removed) are still each
killed on both lanes.
@groeneai

Copy link
Copy Markdown
Collaborator Author

04660 failed on Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel). The granule numbers were the same as everywhere else; only the printed line differed:

-text	Granules: 2/250
+text	│               Granules: 2/250

Under parallel replicas the plan gains a Union above the aggregation, so ReadFromMergeTree is no longer the last top-level child and EXPLAIN prefixes its detail lines with │ (U+2502). trim strips ASCII whitespace, not that byte.

The assertions now read the ratio out of the line with extract(explain, 'Granules: \d+/\d+') instead of trimming a prefix whose shape depends on plan depth. The reference file is unchanged, and extract returns an empty string on a non-matching row, so it stays total over the whole column.

Checked against a binary built from the merge-base copies of both changed sources: all seven granule rows disappear there, on the plain and the parallel-replicas lane alike, so the assertions are not vacuously true. The three mutation arms from the previous round are still each killed on both lanes.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 7c30951

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_tsan) / Hung check failed, possible deadlock found deadlock: a cancelled DROP TABLE prometheus parks in DatabaseCatalog::waitTableFinallyDropped holding the DDLGuard, and 7 further DDL queries convoy behind it #113397 (external, open)
Stress test (amd_msan) / Hung check failed, possible deadlock found same signature, same convoy #113397 (external, open)

Root cause of both rows, read from hung_check.log at this head rather than assumed: the wedged
query is DROP TABLE prometheus with is_cancelled=1 at 924 s (amd_tsan) and 947 s (amd_msan),
parked in waitTableFinallyDropped; every other listed query is a DROP DATABASE/DETACH DATABASE
blocked on DDLGuard::DDLGuard behind it. The prometheus tables in these runs are created by the
PromQL tests (04811_promql_topk_bottomk_limitk*, 04816_promql_shared_subqueries_materialized),
which run with enable_materialized_cte, so the table is pinned by the leaked materialized-CTE plan
graph that #113397 fixes. #113397 is open, so this build does not contain it.

Not caused by this PR's diff: 528 rows across 289 distinct PRs and 62 master runs in the last 7 days.

Build (arm_release) / Post Hooks is not listed: its GitHub check conclusion is success, so the
CIDB row is bookkeeping noise rather than a failure.

Session id: cron:our-pr-ci-monitor:20260811-020000

The file sets transform_null_in = 1 for every query, so `s GLOBAL IN (...)`
reaches index analysis as globalNullIn and `s GLOBAL NOT IN (...)` as
globalNotNullIn (EXPLAIN QUERY TREE prints the resolved name). The bare
globalIn/globalNotIn names that MergeTreeConditionBloomFilterText now maps
were therefore never exercised by this file: with both names deleted from the
mapping the test still passed.

The added arm pins them at transform_null_in = 0, where the same two
predicates keep their bare spellings. With the mapping entries deleted it
fails on the first of the two with INDEX_NOT_USED, which is the only red the
deletion produces in this file.
@clickhouse-gh

clickhouse-gh Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Dear @Ergus, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@Ergus

Ergus commented Sep 21, 2026

Copy link
Copy Markdown
Member

@groeneai Fix the conflicts with master

One conflict, in src/Storages/MergeTree/MergeTreeIndexTextPreprocessor.h.
master renamed the case-folding predicate (isLowerOrUpper/is_lower_or_upper ->
isASCIILowerOrUpper/is_ascii_lower_or_upper) and narrowed it to ASCII
lower/upper, excluding lowerUTF8/upperUTF8: ICU full case mapping can change the
byte length, so those do not tokenize a set element and the index column alike.
I took master's field and comment and kept this branch's is_cast_of_index_column
beside them.

That rename also reaches this branch's only caller. git merged
MergeTreeIndexConditionText.cpp without a conflict because master never touched
the call added here, which passes the predicate as
textIndexSetElementIsComparable's preprocessor_is_case_folding argument, so I
renamed it by hand. The narrower predicate fits that argument's contract more
closely: with lowerUTF8 no longer reported as case folding, a set element under
such a preprocessor keeps the original predicate instead of being answered from
the index.
master's 5ccac9e gave tryParseMapSubcolumnName a second parameter: a column
named `m.key_x` can exist beside a Map `m` and shadows the subcolumn, so the
shape is refused when the name is in that set. The set-analysis path added by
this branch still called the one-argument form, which no longer compiles.

`columns_shadowing_map_subcolumns` is the set every other caller in this file
passes, including hasIndexForMapElementValue, which is what guards this call:
the non-function branch is reached only after that predicate parsed the same
name with the same set, so the optional stays engaged.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master and pushed d210a97; the PR is MERGEABLE again.

Two collisions, both from text-index work that landed meanwhile:

  • MergeTreeIndexTextPreprocessor.h conflicted: c3fca9be2 renamed isLowerOrUpper to isASCIILowerOrUpper and narrowed it to ASCII lower/upper, excluding the UTF-8 variants. I took master's field and comment and kept this branch's is_cast_of_index_column beside them, then renamed the one call this branch added. The narrower predicate is what that call wants: it is passed as textIndexSetElementIsComparable's "maps bytes without consulting their type" argument, and lowerUTF8 can change the byte length, so a set element under such a preprocessor now keeps the original predicate instead of being answered from the index.
  • tryParseMapSubcolumnName gained a shadowing-column-set parameter in 5ccac9e28. git merged that file without a conflict, so it surfaced only at compile time; the call now passes columns_shadowing_map_subcolumns, like every other caller in the file.

Checked on the merged tree: 04660_text_token_index_transform_null_in passes, and the 224-test text_index family plus the tokenbf/ngrambf/bloom_filter/sparse_grams tests behave identically to a master debug build of the same day (same failures, all from my minimal local config, none new). The only difference between the two binaries is that one test, which fails on master and passes here.

@Ergus

Ergus commented Sep 21, 2026

Copy link
Copy Markdown
Member

@groeneai Check #121375 it is my alternative much simpler solution for this issue.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Checked #121375. It is the better change and I support it going in instead of mine.

I ran your test file against my branch: every output matches until the ngrambf_v1 arm with a FixedString set element, which is the one line where the two test files disagree. You are right there and I was wrong. The same query at default settings takes the plain in path, which master already maps, and master prunes it correctly there (26.10.1.1 @ 688ee33):

EXPLAIN indexes = 1 ... s IN (SELECT toFixedString('word1', 12))   ->   Granules: 1/4
count() with the index = 1, with use_skip_indexes = 0 = 1

tryPrepareSetBloomFilter strips the element's NUL padding before tokenizing, and canStripFixedStringPadding counts ngrams, sparseGrams and asciiCJK as padding tolerant, so pruning there is sound. My comparability helper allows splitByNonAlpha only, so on my branch the same query loses the index and force_data_skipping_indices raises INDEX_NOT_USED where master returns 1. Same on a text index with tokenizer = ngrams(3). That is a pruning regression at default settings, and it is mine, not yours.

Your reason for keeping the guard out also holds, measured:

SET enable_full_text_index = 1;
CREATE TABLE t (s FixedString(12), INDEX idx s TYPE text(tokenizer = splitByString))
ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 1;
INSERT INTO t SELECT toFixedString('word' || toString(number), 12) FROM numbers(4);
SELECT count() FROM t WHERE s = 'word1';                                -- 0, Granules: 0/4
SELECT count() FROM t WHERE s = 'word1' SETTINGS use_skip_indexes = 0;  -- 1

Identical on master and on my branch: the guard fixes the IN half and leaves = wrong, as you said. The other two additions in my PR (the mapValues default refusal, the fallback when the preprocessor cannot represent an element) are reachable at transform_null_in = 0 as well, so they do not belong in this fix either.

I found nothing missing or wrong in #121375. I plan to open a separate PR for the FixedString comparability defect, covering = together with IN and taking the tolerated tokenizers from canStripFixedStringPadding instead of my narrower rule. I will close #112785 once #121375 is merged, or now if you prefer.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Correction to my last comment: I am not opening that separate PR. #118972 already covers this defect for = and for IN, and it is the same re-pad lever I proposed on #117021 (#117021 (comment)). It drops canStripFixedStringPadding and spells the needle from the concrete tokenizer instance, and on a FixedString(N) column it looks the needle up re-padded to N instead of as typed.

Measured on master @ 688ee33, that PR's own test case is red today, so it does change this behaviour:

FixedString(6), text(tokenizer = array):
  s = 'hello'                     ->  [1,3] at use_skip_indexes = 0,  [] with the index
  s = toFixedString('hello', 10)  ->  [1,3]                        ,  []

Same binary, the scope of the defect:

  • = loses rows with splitByString and array only. ngrams, sparseGrams and splitByNonAlpha prune correctly, so a narrow allow-list would have cost pruning master performs today.
  • One correction to what I measured above: the IN half is wrong too, just not in the spelling I tried. s IN ('hello') is fine because a literal set is converted to the column type and is therefore already padded, but s IN (SELECT materialize('hello')) and s IN (SELECT toFixedString('hello', 10)) both return [] against a truth of [1,3]. Decline a text-index lookup that cannot cover a padded needle #118972 fixes that half as well, because it types each set element from the set column and re-pads it to the indexed width.
  • ngrambf_v1 and tokenbf_v1 on a FixedString column are unaffected, since both of their tokenizers tolerate the padding. Nothing is left outside the file Decline a text-index lookup that cannot cover a padded needle #118972 rewrites, so a second PR there would only conflict with it.

#118972 also rewrites tryPrepareSetForTextSearch, which this PR edits, so that is one more reason to close this one rather than rebase it.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - d210a97

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build profile diff infra: the job raised RuntimeError: CI logs cluster query failed at build_profile_diff_job.py:234, so nothing was compiled or compared #121048 (external, merged 16:14Z today). Rule 3c: the run started 15:20Z, so the fix is absent from the tree that ran
PR praktika rollup of the row above, not an independent failure #121048 (external, merged)

Every other check is green, including Fast test, Style check, Finish Workflow and
CH Inc sync, and CIDB holds no test-level failure at this head. Mergeable Check is green, so
the single red does not gate merge, and the master merge that would pick up #121048 is deferred on
that measured ground rather than spending a CI cycle on a reporting job that compiles nothing.

Session id: cron:our-pr-ci-monitor:20260921-173143

@rschu1ze rschu1ze closed this Sep 21, 2026
apst41 pushed a commit to apst41/ClickHouse that referenced this pull request Sep 24, 2026
apst41 pushed a commit to apst41/ClickHouse that referenced this pull request Sep 24, 2026
Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for ClickHouse#112785)
@groeneai

Copy link
Copy Markdown
Collaborator Author

Follow-up to my note above. I said there that #118972 covers this and that nothing was left for me to do. That was scoped to master only: #118972 is master-only, carries no *-must-backport label and has no cherry-pick arms, so the wrong results are still live on every supported release line.

Measured this morning on the official per-release binaries from builds.clickhouse.com, at default settings (enable_full_text_index is Production tier with default true, so no SET is needed, and tokenizer is a required text-index argument rather than an opt-in):

CREATE TABLE t (s FixedString(12), INDEX idx s TYPE text(tokenizer = splitByString))
ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 1;
INSERT INTO t SELECT toFixedString('word' || toString(number), 12) FROM numbers(4);
SELECT count() FROM t WHERE s = 'word1';                                -- with the index
SELECT count() FROM t WHERE s = 'word1' SETTINGS use_skip_indexes = 0;  -- truth
binary with the index truth
26.6.9.19 0 1
26.7.14.40 0 1
26.8.11.42 (LTS) 0 1
26.9.2.33 0 1
master 26.10.1.1, 1212 commits after the #118972 merge 1 1

The master row is the positive control: the same script on a post-#118972 binary returns the right answer, so the probe discriminates the fix rather than intended behaviour. #118972's own test case agrees (FixedString(6) with tokenizer = array, s = 'hello' returns [] against a truth of [1,3] on all four release binaries and [1,3] on master), and 05223_text_index_fixed_string_padded_needle is absent from 26.6 through 26.9.

Scope, since it bounds what a backport could disturb: only splitByString and array are affected. ngrams(3), sparseGrams and splitByNonAlpha return the correct count on all four release binaries, so the tolerant tokenizers have nothing to lose.

@Ergus, #121375 carries v26.6/v26.7/v26.8-must-backport and has open cherry-pick arms for 26.7, 26.8 and 26.9, for the sibling defect in the same file. Should #118972 get the same treatment, or is there a reason to leave the released lines as they are? I will not hand-author a cherry-pick either way. If the labels go on and a robot arm conflicts, I am happy to resolve the conflict on my fork and point at it from the robot's PR.

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)
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)
@groeneai

Copy link
Copy Markdown
Collaborator Author

Hi @Ergus, gentle ping on my question above: should #118972 get the same backport labels as #121375? The wrong results still reproduce on 26.6 through 26.9. Thanks.

@rschu1ze

Copy link
Copy Markdown
Member

@groeneai This PR fixes it: #121375

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks. I checked that on builds that have #121375 but not #118972: the current 26.7, 26.8 and 26.9 builds from builds.clickhouse.com, which contain its backports #122237, #122233 and #122228. The transform_null_in = 1 case is fixed there, but the FixedString repro from my comment above still loses rows on all three:

binary s = 'word1' with the index truth
26.7.16.3 0 1
26.8.14.3 0 1
26.9.5.2 0 1
master 26.10.1.1, has both PRs 1 1

#118972's own test case (FixedString(6), tokenizer = array, s = 'hello') also still returns [] against a truth of [1,3] on those three builds, so this one is fixed by #118972, which has no backport.

Should #118972 get the same backport labels as #121375?

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

Labels

can be tested Allows running workflows for external contributors comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants