Repository navigation
Backport text index prewhere filter type fix to 26.3 - #107758
Merged
thevar1able merged 1 commit intoJun 17, 2026
Merged
Conversation
Manual backport of 1c1c031 ("Fix text index prewhere mismatch with multiple indexes") from #98882. With `query_plan_direct_read_from_text_index` and `use_skip_indexes_on_data_read`, the text index read is a `None`-type prewhere step. `MergeTreeRangeReader` executed that step's actions on the sample block in its constructor, while `executePrewhereActionsAndFilterColumns` skips `None`-type steps at runtime. When a row-level filter (e.g. a `ROW POLICY`) reads a `String` column before the `None` step, the sample-block column order diverged from the actual data, so the raw `String` column landed in a filter position and the query raised `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` ("Illegal type String of column for filter"). The fix skips executing step actions on the sample block for `None`-type steps, to match the runtime behavior. It also switches `IndexReadTasks` / `IndexReadColumns` to `std::map` for deterministic iteration order (the multiple-text-index variant of the same class of mismatch). Adds `04332_text_index_direct_read_row_policy` reproducing the single-index `ROW POLICY` case. Verified against public builds bracketing the fix: it raised `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` on 26.4.1.689 (commit c1225a6, before PR #98882) and returns 1000 on 26.4.1.691 (commit 4d79f6e, the PR #98882 merge). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
|
Workflow [BackportPR], commit [f3ffa9e] Summary: ✅ |
nikitamikhaylov
approved these changes
Jun 17, 2026
thevar1able
deleted the
backport-26.3-text-index-filter-prewhere-type-fix
branch
June 17, 2026 19:28
bytehalo-infra
added a commit
to sentioxyz/ClickHouse
that referenced
this pull request
Sep 25, 2026
text index prewhere fix) STOR: with query_plan_direct_read_from_text_index and use_skip_indexes_on_data_read, each text index read is a None-type PREWHERE step. IndexReadTasks/IndexReadColumns were std::unordered_map: the map is copied into the read pool and iterated again in getPrewhereActions and getReadTaskColumns, and a copy need not iterate in the same order, so the PREWHERE readers and the PREWHERE actions of the index steps could be paired differently. In addition MergeTreeRangeReader executed the actions of None-type steps on its sample block although executePrewhereActionsAndFilterColumns skips them at run time, so the sample block and the data diverged. Upstream switches both maps to std::map and skips None-type steps on the sample block (26.3 backport ClickHouse#107758 of 1c1c031 from ClickHouse#98882; 26.4+ have it through ClickHouse#98882). Effect in the fork: with three partially materialized text indexes in one query (04411, third section) the backport of ClickHouse#108607 (a6ab685) ran equals(a, 'alpha') on a column that was not the String column a and failed with TOO_DEEP_RECURSION (KD-UP-TEXTINDEX-DIRECTREAD-3IDX); with a row policy on a String column the upstream test 04332 fails with ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER. Upstream patch unchanged (applies cleanly), with its test 04332_text_index_direct_read_row_policy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bytehalo-infra
added a commit
to sentioxyz/ClickHouse
that referenced
this pull request
Sep 25, 2026
…P-TEXTINDEX-DIRECTREAD-3IDX and KD-ENV-HOSTNAME-SUBSTITUTION KD-UP-107758 (fixed by ebce980): 04332_text_index_direct_read_row_policy fails on the production build a394e92 and on CAND6 with ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER and passes on official 26.8.8.8 and on CAND7; it is added to the selection. KD-UP-TEXTINDEX-DIRECTREAD-3IDX is fixed by the same backport (04411 third section: CAND6 TOO_DEEP_RECURSION, CAND7 correct). KD-ENV-HOSTNAME-SUBSTITUTION is fixed in the test environment by f2f0ba1 (04881 passes with its unchanged reference). Registry 149 entries, 1 open (KD-D512-MIXED-GROUPBY-NULLABLE); 231 selected tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Manual backport of 1c1c031 ("Fix text index prewhere mismatch with multiple indexes") from #98882.
With
query_plan_direct_read_from_text_indexanduse_skip_indexes_on_data_read, the text index read is aNone-type prewhere step.MergeTreeRangeReaderexecuted that step's actions on the sample block in its constructor, whileexecutePrewhereActionsAndFilterColumnsskipsNone-type steps at runtime. When a row-level filter (e.g. aROW POLICY) reads aStringcolumn before theNonestep, the sample-block column order diverged from the actual data, so the rawStringcolumn landed in a filter position and the query raisedILLEGAL_TYPE_OF_COLUMN_FOR_FILTER("Illegal type String of column for filter").The fix skips executing step actions on the sample block for
None-type steps, to match the runtime behavior. It also switchesIndexReadTasks/IndexReadColumnstostd::mapfor deterministic iteration order (the multiple-text-index variant of the same class of mismatch).Adds
04332_text_index_direct_read_row_policyreproducing the single-indexROW POLICYcase. Verified against public builds bracketing the fix: it raisedILLEGAL_TYPE_OF_COLUMN_FOR_FILTERon 26.4.1.689 (commit c1225a6, before PR #98882) and returns 1000 on 26.4.1.691 (commit 4d79f6e, the PR #98882 merge).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER when reading from a text index via query_plan_direct_read_from_text_index together with a row-level filter (such as a row policy) on a String column.