Skip to content

Cherry pick #108607 to 26.5: Fix direct read from multiple partially materialized text indexes - #108666

Merged
robot-clickhouse-ci-1 merged 3 commits into
backport/26.5/108607from
cherrypick/26.5/108607
Jun 26, 2026
Merged

robot-clickhouse-ci-1 merged 3 commits into
backport/26.5/108607from
cherrypick/26.5/108607

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

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-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.

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

CurtizJ and others added 3 commits June 26, 2026 13:08
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
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 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 pr-bugfix Pull request with bugfix, not backported by default labels Jun 26, 2026
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 merged commit f52a4b1 into backport/26.5/108607 Jun 26, 2026
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 deleted the cherrypick/26.5/108607 branch June 26, 2026 22:44
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-bugfix Pull request with bugfix, not backported by default 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.

3 participants