Repository navigation
Cherry pick #108607 to 26.4: Fix direct read from multiple partially materialized text indexes - #108664
Merged
robot-clickhouse-ci-1 merged 3 commits intoJun 26, 2026
Conversation
When a query uses two or more text indexes that are each only partially materialized (added via `ALTER ... ADD INDEX` after data was inserted, so older parts lack the index files), direct read from the text index could throw `Code 107 FILE_DOESNT_EXIST`, e.g. "File for text index stream skp_idx_usert_text_idx.idx does not exist". Each text index gets its own PREWHERE read step holding only its virtual column. For a part where the index is not materialized and the predicate uses Hint mode (e.g. `equals` on a `sparseGrams` index), the virtual column's default expression is the literal `1`, so `injectRequiredColumns` appends the part's minimum-size physical column purely as a row-count anchor. The presence of that physical column is also what made `getIndexReadTaskForReadStep` route the step to the main reader instead of to the text index reader. However, the anchor is the same column for every step, and `getReadTaskColumns` deduplicates columns already read by earlier steps, so only the first index step kept it. The remaining index steps degenerated into pure virtual-column steps and were routed to `MergeTreeReaderTextIndex`, which threw because the index file is absent in that part. Decide the routing based on actual per-part materialization instead: in `getIndexReadTaskForReadStep`, route a step to the text index reader only when `getDeserializedFormat` reports the index is present in the part, otherwise fall back to the main reader (which fills the virtual column from its default expression). The behavior is unchanged for materialized parts. Closes: #108530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…materialization Fix direct read from multiple partially materialized text indexes
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.
Original pull-request #108607
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-picklocally.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.
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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job