Repository navigation
Fix addDays and other date add functions throwing on rows rejected by a short-circuit condition - #128895
Fix addDays and other date add functions throwing on rows rejected by a short-circuit condition#128895murphy-4o wants to merge 3 commits into
addDays and other date add functions throwing on rows rejected by a short-circuit condition#128895Conversation
|
Workflow [PR], commit [33281f5] Summary: ✅
AI ReviewSummaryThis PR makes throwing Findings
SELECT sum(if(ds != 'x',
addDate(ds, INTERVAL 1 DAY) > toDateTime('2000-01-01'), 0))
FROM
(
SELECT if(number % 10 = 0, 'x', '2020-01-01') AS ds
FROM numbers(100)
);Tests
Final VerdictStatus: |
… a short-circuit condition A String first argument is parsed per row, a UInt64 or floating-point delta can overflow Int64, and the delta is scaled to ticks with an overflow check for sub-second units and seconds on DateTime64/Time64 and for sub-second units with an Int64 delta on DateTime. isSuitableForShortCircuitArgumentsExecution returned false for all of them, so a preceding condition in and/if/PREWHERE did not keep the rejected rows away from these functions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
59ca5b7 to
82aeb24
Compare
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units29 translation units recompiled, 87 s compile time in total, 29 of them have a recent master baseline. |
…lity dictionary values and NULL rows A rejected value stays in the dictionary of a filtered LowCardinality column, and the nested value behind a NULL is arbitrary; executing on them threw. Decline execution on default arguments, like conversions do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts comments Co-Authored-By: Claude Opus 5.5 <[email protected]>
addDaysand the otheradd*/subtract*functions told short-circuit evaluation that they never throw, so a guard in front of them did not protect them. A String date is parsed for every row, so this query failed on the rows the guard rejects:The same happened in
if(cond, addDays(...), ...)and inPREWHERE.WHEREusually worked only because the plan splits theANDchain into separate filters.isSuitableForShortCircuitArgumentsExecutionnow returnstruefor the inputs that can throw:UInt64or floating-point delta that does not fitInt64;DateTime64/Time64, and sub-second units with anInt64delta onDateTime.Other Date and DateTime arithmetic cannot throw and stays eager.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
addDaysand the otheradd*/subtract*date functions throwing for rows that a preceding condition inAND,iforPREWHERErejects, for exampleds != 'x' AND addDays(ds, 1) > now()on a String column.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/128895]