Repository navigation
Conversation
`bloom_filter` and text indexes now look through `CAST(x, 'T')` where `x` is `Nullable(T)`, e.g. a typed JSON path `Nullable(String)` read as `::String`. The cast does not change a non-NULL value and throws on NULL. A query that would throw may not throw if the index skips the granules with NULL or the text index is read directly; this is accepted. Related: ClickHouse#123239 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Workflow [PR], commit [9a262f8] Summary: ✅
AI ReviewSummaryThis PR teaches Findings
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit 9a262f8.
Changed lines: Changed C/C++ lines covered: 36/36 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units357 translation units recompiled, 3685 s compile time in total, 357 of them have a recent master baseline. |
…able` Direct read replaces or short-circuits the predicate, so the `CAST` no longer throws on NULL: `NOT hasToken(CAST(s, 'String'), 'a')` returned the NULL row instead of raising `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN`. `unwrapLosslessConversion` gets an `allow_drop_nullable` flag. The optimizer uses direct read only if the predicate also matches the index with `allow_drop_nullable = false`, otherwise the index is used only to skip granules. Related: ClickHouse#124220 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ex condition Do not pass `allow_drop_nullable` through `MergeTreeIndexConditionText`. The optimizer disables direct read if `unwrapLosslessConversion` of an argument of the predicate stops earlier with `allow_drop_nullable = false`. Related: ClickHouse#124220 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
| @@ -0,0 +1,59 @@ | |||
| -- Skip indexes look through a `CAST` that drops `Nullable` from the indexed column. It does not change a non-NULL | |||
| -- value, and it throws on NULL. A query that would throw does not throw if the granules with NULL are skipped. | |||
There was a problem hiding this comment.
That CAST(Null, String`) throws is the expected behavior and it says the same here (l. 2).
For my understanding, we cannot throw an exception on the index paths because the bloom filter and text indexes don't store Nulls, right?
There was a problem hiding this comment.
Yes, skip indexes don't store nulls.
Cherry pick #124220 to 26.7: Use skip indexes through a `CAST` that drops `Nullable`
Cherry pick #124220 to 26.8: Use skip indexes through a `CAST` that drops `Nullable`
Cherry pick #124220 to 26.9: Use skip indexes through a `CAST` that drops `Nullable`
Backport #124220 to 26.9: Use skip indexes through a `CAST` that drops `Nullable`
Backport #124220 to 26.8: Use skip indexes through a `CAST` that drops `Nullable`
Backport #124220 to 26.7: Use skip indexes through a `CAST` that drops `Nullable`
Related: #123239
A follow-up to #123239.
bloom_filterand text indexes now also look through aCASTthat dropsNullablefrom the indexed column, e.g.CAST(x, 'String')forx Nullable(String), or a typed JSON pathNullable(String)read asDocument.TypeName::String. A user needs this for the second case.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
bloom_filterand text indexes are now used when aNullableindexed column is cast to the non-Nullabletype, such asCAST(x, 'String')orjson.path::String. A query that would throw on a NULL value may not throw when the index skips the granules with NULL.Workflow [PR]
Sync PR [sync-upstream/pr/124220]
Version info
26.10.1.1785-master(included in26.10and later)26.9.13.17,26.8.21.11,26.7.26.3