Repository navigation
Conversation
`ToStringMonotonicity` unwrapped `LowCardinality` but not `Nullable`, so for a `Nullable` key every type guard was skipped and the generic branch declared `toString` monotonic: an `Enum`, a `Time`, or a `DateTime` whose time zone turns the clocks back was pruned as if the order of the strings matched the order of the values, and rows were dropped or counted twice. `Nullable` now comes off like `LowCardinality`; where `toString` is monotonic on the wrapped type a `Nullable` key is pruned like a plain one, and `ORDER BY toString(key)` reads in order, `NULL` last in both orders. `CAST(key AS String)` resolves to the same struct. On a part holding a `NULL` the index analysis evaluates the chain over the index column, whose last mark is that `NULL`, so `CAST` to a non-`Nullable` type raises the same error the row-level evaluation would, as `CAST` to `Date` does on a `Nullable(DateTime)` key today; nothing is hidden by pruning. Read in key order, `LIMIT` stops before the `NULL` row, as it does for `CAST` to `Date` today.
|
Workflow [PR], commit [60784b8] Summary: ✅
AI ReviewSummaryThis PR fixes the original wrong-results bug by unwrapping Final Verdict✅ No new findings. LLVM Coverage ReportMeasured on commit 60784b8.
Changed lines: Changed C/C++ lines covered: 12/12 (100.00%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
…y check `KeyCondition` asked `ToStringMonotonicity` about the key's own time zone, while `toString(d, 'America/New_York')` formats in the argument's: a fixed-offset key formatted in a zone that turns the clocks back was declared strictly monotonic and mis-pruned. The constant is substituted into the type as for the date functions. Predates the `Nullable` unwrap, which reaches this branch for one more wrapper.
DRAFT / work in progress. The description is being rewritten; the code is unchanged.
ToStringMonotonicityunwrappedLowCardinalitybut notNullable, so for aNullablekey every type guard was skipped and the generic branch declaredtoStringmonotonic: anEnum, aTime, or aDateTimein a time zone that turns the clocks back was pruned as if the order of the strings matched the order of the values, and rows were dropped or counted twice.Nullablenow comes off likeLowCardinality; wheretoStringis monotonic on the wrapped type (String,Date, a fixed-offsetDateTime) aNullablekey is pruned like a plain one, andORDER BY toString(key)reads in order,NULLlast in both orders.CAST(key AS String)resolves to the same struct. On a part holding aNULLthe index analysis evaluates the chain over the index column, whose last mark is thatNULL, soCASTto a non-Nullabletype raises the error the row-level evaluation would, asCASTtoDatedoes on aNullable(DateTime)key today. Nothing is hidden by pruning. Read in key order,LIMITstops before theNULLrow is reached, as it does forCASTtoDatetoday.05230pins the error, the pruning on a part withoutNULL, andORDER BY CAST(...) LIMITwith read-in-order on and off.Closes: #119557
Supersedes: #120680
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed wrong results of
WHERE toString(key) = ...andINon aNullableprimary key of a type on whichtoStringis not monotonic (Enum,Time,DateTimewith a time zone that turns the clocks back): the index treated the function as monotonic and pruned matching granules.