Skip to content

Text index: fix read mode of LIKE/ILIKE with an index built on a container - #114544

Merged
ahmadov merged 1 commit into
masterfrom
ahmadov/text-index-like-container-hint
Aug 13, 2026
Merged

ahmadov merged 1 commit into
masterfrom
ahmadov/text-index-like-container-hint

Conversation

@ahmadov

@ahmadov ahmadov commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Evaluating LIKE/ILIKE by scanning the text index dictionary always used an exact direct read, which removes the original condition from the query plan. That is only valid when a matching dictionary token proves the predicate, which is not the case when the index is built on a container while the predicate reads a single element out of it: with an index on mapValues(m), m['a'] LIKE '%foobar%' also returned rows whose match is under another key. However, it may produce correct result due to the data, but it's not guaranteed.

To ensure for producing correct results, we need to use HINT mode when a text index built on a container (Map or JSON).

It is better to be safe than sorry.

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

Fix text index evaluation of LIKE/ILIKE operator built on Map or JSON containers.

Version info

  • Merged into: 26.8.1.1313 (included in 26.8 and later)

…ainer

Evaluating `LIKE`/`ILIKE` by scanning the text index dictionary always
used an exact direct read, which removes the original condition from the
query plan. That is only valid when a matching dictionary token proves
the predicate, which is not the case when the index is built on a
container while the predicate reads a single element out of it: with an
index on `mapValues(m)`, `m['a'] LIKE '%foobar%'` also returned rows
whose match is under another key. However, it may produce correct result
due to the data, but it's not guaranteed.

To ensure for producing correct results, we need to use `HINT` mode when
a text index built on a container (Map or JSON).

It is better to be safe than sorry.
@ahmadov
ahmadov requested a review from rschu1ze August 12, 2026 21:22
@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c1e6b38]

Summary: ✅


AI Review

Summary

This PR changes LIKE/ILIKE dictionary-scan evaluation on container-backed text indexes so predicates over mapValues(...) / JSONAllValues(...) stay in hint mode instead of being treated as exact direct reads. I reviewed the current diff, the surrounding MergeTreeIndexConditionText / direct-read consumers, the added stateless coverage, the existing PR discussion, and the current CI state, and I did not find a remaining correctness or compatibility issue at the current HEAD.

Final Verdict

✅ No actionable findings.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.00% 79.10% +0.10%

Changed lines: Changed C/C++ lines covered: 29/32 (90.62%) · 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 12, 2026
@rschu1ze rschu1ze self-assigned this Aug 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c1e6b3844 with master 405e218ff (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
Binary Master PR Δ
programs/clickhouse-stripped 692.09 MiB 689.09 MiB -3.00 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

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

Job report

@ahmadov
ahmadov enabled auto-merge August 13, 2026 07:25
@ahmadov
ahmadov disabled auto-merge August 13, 2026 07:25
@ahmadov
ahmadov added this pull request to the merge queue Aug 13, 2026
Merged via the queue into master with commit 32385c7 Aug 13, 2026
181 checks passed
@ahmadov
ahmadov deleted the ahmadov/text-index-like-container-hint branch August 13, 2026 09:06
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 13, 2026
ahmadov added a commit that referenced this pull request Sep 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 25, 2026
…/ILIKE with an index built on a container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants