Skip to content

Fix skip index analysis through casts and on missing map keys or JSON paths - #124612

Merged
CurtizJ merged 2 commits into
ClickHouse:masterfrom
CurtizJ:skip-index-lossless-conversion-fixes
Oct 9, 2026
Merged

CurtizJ merged 2 commits into
ClickHouse:masterfrom
CurtizJ:skip-index-lossless-conversion-fixes

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Fixes three issues found after #123239 and #124220, which let skip indexes look through lossless conversions of the indexed column.

Closes: #124385
Closes: #124541
Closes: #124540
Related: #123239
Related: #124220

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

Fixed a query failing with an exception like Cannot parse UInt64 from String on a table with a text index on mapKeys or JSONAllPaths, when the predicate cannot be evaluated on the value of a missing map key or JSON path.


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

Version info

  • Merged into: 26.10.1.1936-master (included in 26.10 and later)
  • Backported to: 26.9.14.12, 26.8.23.5, 26.7.28.4

… paths

- `isLosslessConversion` compares type names instead of `equals`, which ignores
  the time zone of `DateTime` and the custom name of `Bool`. A `bloom_filter`
  index skipped matching rows for `CAST(dt, 'DateTime(\'UTC\')') = '...'` and
  `CAST(u, 'Bool') = true`.
- The text index preprocessor is applied on top of a `CAST` that drops
  `Nullable`, so `NOT hasToken(CAST(s, 'String'), ...)` still throws on NULL
  instead of returning the NULL rows.
- A text index on `mapKeys` or `JSONAllPaths` evaluates the predicate on the
  value of a missing key or path with `ActionsDAG::evaluatePartialResult`. If it
  throws, e.g. `toUInt64('')`, the index does not answer the predicate, as in
  `filterResultForNotMatchedRows`. Previously the query failed.

Closes: ClickHouse#124385
Closes: ClickHouse#124541
Closes: ClickHouse#124540

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [870c9ad]

Summary: ✅


AI Review

Summary

This PR fixes three skip-index regressions introduced by the recent cast-looking-through work: wrong-result bloom_filter pruning across time-zone/Bool casts, unsound row-level text-index rewriting across a CAST that drops Nullable, and text-index condition construction that throws while probing the default value for missing map keys / JSON paths. I did not find a remaining correctness issue in the current code; the new stateless tests cover both the silent-wrong-results and analysis-time-exception repros, and the linked CI run is fully green.

PR Metadata
  • Changelog category: Bug Fix is correct for the user-visible correctness fixes here.
  • Changelog entry: required, but the current text is too narrow: it only describes the mapKeys / JSONAllPaths exception case and omits the bloom_filter wrong-results fix plus the text-index CAST / Nullable fix.
  • Exact replacement text: Fixed skip-index analysis through unsafe casts: prevented wrong results for bloom-filter indexes on time-zone/Bool casts, preserved exception semantics for text-index predicates rewritten through Nullable-dropping CASTs, and stopped text indexes on mapKeys/JSONAllPaths from throwing when default-value probing cannot evaluate the predicate.
Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 870c9ad.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 42/42 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 8, 2026
@CurtizJ CurtizJ added pr-bugfix Pull request with bugfix, not backported by default and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Oct 8, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... label Oct 8, 2026
@CurtizJ CurtizJ self-assigned this Oct 9, 2026
@CurtizJ
CurtizJ added this pull request to the merge queue Oct 9, 2026
@CurtizJ CurtizJ added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 9, 2026
Merged via the queue into ClickHouse:master with commit 1bc3e78 Oct 9, 2026
152 checks passed
@CurtizJ
CurtizJ deleted the skip-index-lossless-conversion-fixes branch October 9, 2026 12:35
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 9, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 9, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 9, 2026
Backport #124612 to 26.9: Fix skip index analysis through casts and on missing map keys or JSON paths
robot-clickhouse-ci-2 added a commit that referenced this pull request Oct 10, 2026
Cherry pick #124612 to 26.7: Fix skip index analysis through casts and on missing map keys or JSON paths
robot-clickhouse added a commit that referenced this pull request Oct 10, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Oct 10, 2026
Cherry pick #124612 to 26.8: Fix skip index analysis through casts and on missing map keys or JSON paths
robot-clickhouse added a commit that referenced this pull request Oct 10, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 10, 2026
Backport #124612 to 26.8: Fix skip index analysis through casts and on missing map keys or JSON paths
clickhouse-gh Bot added a commit that referenced this pull request Oct 11, 2026
Backport #124612 to 26.7: Fix skip index analysis through casts and on missing map keys or JSON paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

3 participants