Repository navigation
Conversation
changeYear/Month/Day/Hour/Minute/Second over DateTime64(N) built the result column at the hardcoded default scale 3 instead of N, because the `is_same_v<InputDataType, DateTime64>` guard was always false (InputDataType is a DataType class, DateTime64 a value-type alias). Read the scale from result_type instead. timeSlots over DateTime64 declared Array(DateTime64(max(start, duration))) and built the values column at start scale, ignoring the optional Size argument scale that the value rescaling uses (max(start, duration, size)). Include the Size scale in the declared return type and build the column at the declared scale. Both produced a column whose physical scale diverged from its declared type; feeding it into a structure-sensitive consumer (arrayPush/arrayConcat over Array(DateTime64(N))) skipped the cast on declared-type equality and reached the generic writeSlice, whose ColumnDecimal::structureEquals raised a LOGICAL_ERROR. These are the two producer fixes from ClickHouse#108551 (reverted by ClickHouse#108981 for an unrelated reason: its strict columnMatchesType stress-test gate reddened FunctionsStress.stress). This change re-lands only the producer fixes without the gate. Related: ClickHouse#108517 Related: ClickHouse#108981
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260630-201200 |
|
cc @rschu1ze @Algunenano - could you review this? It re-lands the two producer fixes from the reverted #108551 (changeDate building the DateTime64 result column at default_scale 3 due to an always-false |
|
Workflow [PR], commit [5ddb58b] Summary: ✅
AI ReviewSummaryThis PR fixes two producer-side Final VerdictStatus: ✅ Approve No blocking or major findings. I did not post inline review comments. |
CI finish ledger — 5ddb58bCI fully finished (Finish Workflow = success). One test failure, not PR-caused; owned by an existing external fix PR.
The changeDate/timeSlots DateTime64 scale fixes and the regression test Session id: cron:our-pr-ci-monitor:20260701-033000 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 18/18 (100.00%) · Uncovered code |
87bfca8
|
Hi — this looks like a backport candidate for |
…cer-datetime64-decimal-scales Fix changeDate and timeSlots DateTime64 result column scale
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
changeYear/changeMonth/changeDay/changeHour/changeMinute/changeSecondoverDateTime64(N)building the result column at the hardcoded default scale 3 instead ofN, andtimeSlotsoverDateTime64ignoring the optionalSizeargument scale in its declared return type. Both produced a column whose physical scale diverged from its declared type, which led to aLOGICAL_ERROR(writeSlice expects same column types) when the result was passed toarrayPushBack/arrayPushFront/arrayConcat, andtimeSlotswith the largest scale inSizereturned wrong timestamps.Description
Re-lands the two producer fixes from #108517 (originally in #108551, reverted by #108981 for an unrelated reason: that PR also added a strict
columnMatchesTypescale gate to the function property stress test, which reddenedFunctionsStress.stress). This change re-lands only the producer fixes, without the gate, so it cannot affect the stress test.changeDate: theDataTypeDateTime64result branch built the column atDataTypeDateTime64::default_scale(3) because theif constexpr (std::is_same_v<InputDataType, DateTime64>)guard was always false (InputDataTypeis aDataTypeclass,DateTime64a value-type alias). The values were computed at the declared scaleN, so aDateTime64(N != 3)result carried a physically scale-3 column. Now reads the scale fromresult_type.timeSlots:getReturnTypeImpldeclaredArray(DateTime64(max(start_scale, duration_scale)))andexecuteImplbuilt the values column atstart_scale, butTimeSlotsImplrescales values tomax(start_scale, duration_scale, time_slot_scale). The 3rdSizeargument scale is now included in the declared return type, and the column is built at the declared scale read fromresult_type.Either divergence is invisible to a same-declared-type cast, so feeding the result into a structure-sensitive consumer (
arrayPush*/arrayConcatoverArray(DateTime64(N))) reached the genericwriteSlice, whoseColumnDecimal::structureEqualsraised theLOGICAL_ERROR. The production check is correct and unchanged; the fix makes each producer build a column consistent with its declared type.Regression test
04338_changedate_datetime64_scale_array_push(parallel-safe) covers both functions overDateTime64(N != 3)through the array consumers. It raises thewriteSliceLOGICAL_ERRORon clean master (server abort in debug/sanitizer builds) and passes with the fix.The
reinterpretproducer of the same divergence is fixed separately in #108878.Version info
26.7.1.710(included in26.7and later)