Repository navigation
Conversation
…functions compare it
`equals`, `hasAny`/`hasAll`, and `has`/`indexOf`/`mapContains*` over a
non-LowCardinality element compare a `Date32` with a `DateTime('tz')` in
their least supertype, `DateTime64(0)` without a time zone, i.e. in the
session time zone. The `bloom_filter` index converted the constant straight
to the element type, and the `Date32 -> DateTime` conversion reads the date
in the column's time zone. With `session_timezone = 'UTC'` and a
`DateTime('Europe/Moscow')` column the index hashed midnight MSK while the
function compared midnight UTC, so the granule holding the match was pruned
(found by the AST fuzzer's TLP oracle on PR ClickHouse#112650).
Convert such a constant through the same `getLeastSupertype`, then strictly
back to `DateTime`; a date outside the `DateTime` range yields Null and the
index declines. The helper is used at every probe site that compares like
the search functions, with the same LowCardinality rule as the string
coercion. The `m['k'] = const` branch over `mapValues` hashed the constant
unconverted; a date constant is now converted there too, which also fixes
`BAD_GET` for a `DateTime64` constant, and the missing-key default is
re-checked on the converted value.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
`mapContainsValue(mv, toDate32(..))` over a `mapValues` bloom_filter index goes through the same `convertConstantForArrayIndexFunction` path as `mapContainsKey`; on master it returns 0 instead of 1 here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 rounds, 1 finding) plus my own review (3 findings), at a8df0aa.
Not changed here: Severity: ❌ blocker / |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261028-114500 |
|
cc @alexey-milovidov @shankar-iyer, could you review this and add the |
|
Workflow [PR], commit [7965396] Summary: ❌
AI ReviewSummaryThe change fixes incorrect Final Verdict✅ Approve. |
…loom_filter index
The default check for `m['k'] = <date constant>` ran only on the `mapValues`
path, after the index was chosen, so a `mapKeys` index (alone or with a
`mapValues` index) still probed the absent key and pruned rows whose missing
key equals the constant, e.g. `m['missing'] = toDate32('1970-01-01')` over
`Map(String, DateTime('Europe/Moscow'))` under `session_timezone = 'UTC'`.
Run the check before the index is chosen and do it the way `equals` does:
the missing key's column default (zero, `1970-01-01`, also for `Date32`,
whose `getDefault` is `1900-01-01`) and the constant are compared in their
least supertype. The converted constant is still what the `mapValues` index
hashes. Only date-like constants over date-like map values are affected; a
non-date constant on the `mapKeys` path keeps the existing behaviour.
Reported by the automated review on the PR.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - aed24fbEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 179 check runs completed and Session id: cron:our-pr-ci-monitor:20261028-203004 |
…-session-time-zone # Conflicts: # src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes3 object files changed (+20.13 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units7 translation units recompiled, 19 s compile time in total, 7 of them have a recent master baseline. |
…stant
`RPNBuilderTreeNode::tryGetConstant` returns the `Field` of a `Variant` or
`Dynamic` constant's active member but keeps the wrapper as its type, so the
day number of a `Date`/`Date32` member (or the ticks of a `DateTime64` one)
reached `convertFieldToType` with no unit. Against a date-like index element
the index then either probed the day number as seconds and pruned matching
granules (`dt = CAST(toDate('2024-01-05') AS Dynamic)` returned 0 instead of
1, also through `m['k'] = ...`), or threw `TYPE_MISMATCH` while the condition
was prepared (`Date32` and `DateTime64` members, any `Variant(Date32, ...)`).
Both reproduce on master with default settings.
Decline the index for such a constant against a `Date`, `DateTime` or
`DateTime64` element in every path: the scalar and array conversions, a
`Variant`/`Dynamic` constant array, and the `m['k'] = ...` branch (both the
keys and the values index, since the missing-key check needs the constant's
type too). Pruning for typed date constants is unchanged.
Part pruning by statistics (and the primary key and `minmax` index) still drop
the row for a `Dynamic(Date32)` constant on master; that is `KeyCondition`'s
defect, tracked separately, so the two `Date32` test queries turn it off.
Reported by clickhouse-gh[bot] in
ClickHouse#128052 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 7965396Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261115-210011 |
Related: #117318
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
bloom_filterskip index dropping rows when aDate32constant is compared with an indexedDateTimecolumn whose time zone differs fromsession_timezone(in=,has,hasAny,hasAll,indexOf,mapContains*andm['key'] = ...). Also fixed a missing map key equal to a date constant inm['key'] = ...making amapKeysormapValuesindex skip the row, aBAD_GETexception for aDateTime64constant over amapValuesindex, and wrong results or aTYPE_MISMATCHexception for aVariantorDynamicconstant holding a date.Description
On 26.9.19.9,
SELECT count() FROM t WHERE hasAny(arr, [toDate32('2024-01-02')])overarr Array(DateTime('Europe/Moscow'))withINDEX bf arr TYPE bloom_filterandsession_timezone = 'UTC'returns 0, whileuse_skip_indexes = 0returns 1. Found by the TLP oracle of AST fuzzer (amd_release, oracle).Root cause: the search functions compare a
Date32with aDateTime('tz')in their least supertype,DateTime64(0)without a time zone, i.e. in the session time zone. The index converted the constant straight to the element type withconvertFieldToType(the column's time zone) and pruned the matching granule. Form['key'] = <date>it did not convert the constant formapValues, and its missing-key check used the default of the constant's type. AVariantorDynamicconstant arrives as its member's value without the member's type, so a day number was read as seconds or the conversion threwTYPE_MISMATCH.Change:
convertConstantLikeSearchFunctionconverts aDate32constant against aDateTimeelement through the samegetLeastSupertype, then exactly back toDateTime(out of range: the index declines), at every probe site. Form['key'] = <date>both map indexes decline when a missing key's value equals the constant in that supertype. AVariantorDynamicconstant makes it decline for a date or time element. Pruning for typed constants is kept (1 of 10 granules read, not 0).Validation: the new test fails on master (fifteen predicates return 0, three throw) and passes with the fix; 50/50 randomized runs; the
bloom_filterstateless tests pass.Not changed:
dt IN (SELECT toDate32(...))and a non-date constant equal to a missing key on themapKeyspath, both checked by #117318. Part pruning by statistics, the primary key andminmaxstill drop the row for aDynamic(Date32)constant (KeyCondition, like #125914); the test turns statistics off for those two queries.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/128052]