Repository navigation
Reject a non-finite WITH FILL bound - #118434
Conversation
`ORDER BY x WITH FILL TO nan` (and `TO inf`) generated fill rows until the query hit a time limit, and forever without one: `FillingRow::next` guards the fill cursor and the data rows against `NaN`/`Inf`, but compares them against the `TO` bound unguarded, and `NaN` compares greater than every value in the totalized `Field` order, so the loop's termination test was always true. A `LIMIT` does not stop it either, and validation accepted the bound because `less(0, nan)` reads as a positive fill direction. Such a bound is rejected now with `INVALID_WITH_FILL_EXPRESSION`, like the other unusable `WITH FILL` parameter combinations, on both analyzers. `FROM` and `STEP` are left alone: a non-finite value there is already handled by the run-time guards in the fill loop and those queries return correct results. Closes: #118122 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [e667913] Summary: ✅
AI ReviewSummaryThis PR closes the non-finite Final Verdict✅ No new findings in the current diff. LLVM Coverage ReportMeasured on commit e667913.
Changed lines: Changed C/C++ lines covered: 13/13 (100.00%) · Uncovered code |
|
TL;DR: the check closes the
SELECT count()
FROM (SELECT toFloat64(number) AS x FROM numbers(3) ORDER BY x WITH FILL STEP 1 STALENESS nan)
SETTINGS max_execution_time = 3; -- TIMEOUT_EXCEEDED; runs forever at the default 0Extending the same finiteness check to
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline. |
…nite-118122 # Conflicts: # src/Interpreters/InterpreterSelectQuery.cpp # src/Planner/PlannerSorting.cpp
…on moved to `checkFillDescription` Master unified the `WITH FILL` validation of both analyzers into `checkFillDescription`, so the finiteness check lives there now and covers both analyzers at once. `STALENESS` reaches the same fill loop as `TO`: `updateConstraintsWithStalenessRow` derives the loop constraint from it exactly like from `TO`, and `FillingRow::next` compares that constraint unguarded, so `ORDER BY x WITH FILL STEP 1 STALENESS nan` (also `inf`, and `-inf` with `DESC`) kept generating the suffix forever, the same defect this change fixes for `TO`. Both are rejected with `INVALID_WITH_FILL_EXPRESSION` now, and the stateless test covers the `STALENESS` shapes on both analyzers. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Updated: merged (which had unified the validation of both analyzers into On the two CI reds of the previous commit:
|
|
🕵 (fixing the two words the shell ate in the first sentence above: merged |
|
It is already in progress, and it is yours: #118094 (default The open issue for the signature is your own #117681 (the usage side far above real usage, every query refused), plus #113060 for the per-user tracker. Neither is reachable from the CI row: the row is named The run you linked is that class: Re-measured today over 30 days, Two notes on the part that is not in progress, where the steps come from:
One thing worth deciding: #117738 says I will take the origin of the steps and report on #117681, unless you would rather I stayed off it. |
…nite-118122 # Conflicts: # src/Core/SortDescription.cpp Co-authored-by: yakov <[email protected]>
|
|
this is not correct - |
`FROM` was left out of the finiteness check on the grounds that the run-time
guards in `FillingRow::next` already handle it and the query returns correct
results. They do not: a non-finite `FROM` puts the fill cursor exactly where
those guards stop the fill, so the bound itself is emitted as a row and the
fill rows a finite `TO` asks for are silently dropped. Measured on 26.10.1.65:
ORDER BY x WITH FILL FROM -inf TO 3 STEP 1 over {0.0, 1.0} -> -inf, 0, 1
ORDER BY x WITH FILL FROM -1 TO 3 STEP 1 over {0.0, 1.0} -> -1, 0, 1, 2
ORDER BY x DESC WITH FILL FROM inf STEP -1 over {0,1,2} -> inf, 2, 1, 0
Wrong results are worse than the hang this change started from, so `FROM` is
rejected on the same rule as `TO` and `STALENESS`.
Also replace the local lambda with `Field::isNaN` and `Field::isInf`, which are
the same predicate and are what `FillingRow::next` already uses for the row side
of this invariant, and drop the `NaNUtils.h` include that the lambda needed.
Co-authored-by: yakov <[email protected]>
Three things were missing or stale:
* The shapes that do not hang but fill nothing (`ASC ... TO -inf`, `DESC ... TO
nan`, `DESC ... TO inf`) returned their rows before and throw now. They are
the only user-visible regression risk here, so they are pinned rather than
left as an unstated side effect of the check.
* `SETTINGS enable_analyzer = 0` no longer selects the old analyzer: since v26.9
the setting is frozen at `1` and disabling it is rejected with
`SETTING_CONSTRAINT_VIOLATION`, so those cases asserted the wrong error after
merging `master`. Dropped, along with the `FROM`/`STEP` claim they backed.
* A bound reached through an expression or a cast (`TO -log(0)`,
`TO CAST('inf', 'Float32')`) is checked after evaluation, not only as a
literal, and both hung before.
Renamed off `..._with_fill_to_non_finite`, which named only the `TO` bound, and
renumbered to the next free prefix, 05112 having gone stale.
Co-authored-by: yakov <[email protected]>
WITH FILL TO bound that the fill loop can never passWITH FILL bound
`STEP` was the last parameter left accepting `NaN`/`Inf`, and it fails the same
way `FROM` does: the first step makes the cursor non-finite, which is where the
guards inside `FillingRow::next` stop the fill, so the query silently returns
its rows unfilled. Measured on 26.10.1.65 over the rows 0.0 and 1.0:
ORDER BY x WITH FILL FROM 0 TO 4 STEP nan -> 0, 1
ORDER BY x WITH FILL FROM 0 TO 4 STEP 1 -> 0, 1, 2, 3
Rejecting it leaves no `WITH FILL` parameter where a non-finite value is taken
and quietly ignored, which is the point of the check: a bound that cannot
produce a fill should say so instead of returning a plausible-looking result.
An `INTERVAL` step is unaffected - `step_kind` implies an integer or decimal
value, which is never non-finite.
Co-authored-by: yakov <[email protected]>
`deserializeSortDescription` is a client-facing entrypoint of its own: a forged query plan reaches `checkFillDescription` without passing through the parser or either analyzer, so the stateless test `05227_with_fill_non_finite_bound` does not prove that a serialized `NaN`/`Inf` bound is rejected there. Add the missing `expectRejected` cases for `fill_from`, `fill_to`, `fill_step` and `fill_staleness`, asserting the finiteness message so that a regression cannot silently shift the rejection to another check, and let `expectRejected` assert the message text. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Updated. @yakov-olkhovskiy — noted that you are taking over; this pass only did the mechanical work, nothing that conflicts with your commits.
One thing that needs a human: the CLA check is red because
|
…nite-118122 Co-authored-by: yakov <[email protected]>
The previous commit left every generated value to the runtime checks in `FillingRow::next`. That is exact, but for a fill with `FROM` it reports a certain wraparound only after generating every value up to the boundary of the column type: `WITH FILL FROM 0 TO 4294967297` over a `DateTime` column first generates 2^32 rows. A fill with `FROM` generates the same sequence for any data (even an empty input), so judging it up front is exact as well, and it fails fast - restore those checks (`TO` against the last generated value, the `INTERVAL` walk, the `Int64` carrier wrap). Only the up-front check of fills without `FROM` stays removed: it had to approximate the data-anchored sequence and rejected queries that never wrap - an empty input filled `TO 1025` over `UInt8`, and `ORDER BY d DESC WITH FILL TO -5 STEP INTERVAL -1 YEAR` over `Date`, which stops at `1970-01-01` because the calendar arithmetic saturates there. Also adapt the test to #118434, merged from master, which rejects a non-finite `TO` up front. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A
NaNorInfvalue is not usable as anyWITH FILLparameter, and each one fails in its own way.Towards the fill direction,
NaNcompares greater than every value in the totalizedFieldorder, so theloop's termination test in
FillingRow::nextis always true and the query generated fill rows until it hita time limit, and forever without one:
FillingRow::nextguards the fill cursor and the data rows againstNaN/Inf(the fixes for #69261), butcompares them against the loop constraint unguarded, and validation accepted the bound because
less(0, nan)reads as a positive fill direction. ALIMITdoes not stop it either.STALENESSreachesthe same constraint:
updateConstraintsWithStalenessRowderives it from the staleness value exactly likefrom
TO, and writes it into the same array.A
TObound the fill runs away from does not hang, it is passed at once and nothing is filled. Anon-finite
FROMorSTEPmakes the cursor itself non-finite, which is where the guards insideFillingRow::nextstop the fill, so nothing is filled either — and forFROMthe bound has by then beenemitted as a row, replacing the fill a perfectly good
TOasked for. Measured on 26.10.1.65 over the rows0.0and1.0:All four parameters are rejected now with
INVALID_WITH_FILL_EXPRESSION, like the other unusableWITH FILLcombinations. The check lives incheckFillDescription, so it covers the planner and the queryplan deserializer alike.
Of the eighteen rejected shapes, nine hung before and nine returned rows, so this is a small
backward-incompatible tightening for values that could never produce a correct fill. The same precedent
already exists for a vacuous
TObeyondFROM.Closes: #118122
Related: #118438
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
A non-finite
FROM,TO,STEPorSTALENESSvalue inORDER BY ... WITH FILL(nan,infor-inf)is now rejected with
INVALID_WITH_FILL_EXPRESSION. Previously such a value either made the query generatefill rows endlessly (
TO nan,TO infascending,TO -infdescending, and the same values forSTALENESS) or produced a wrong result: a non-finiteFROMemitted the bound itself as a row and droppedthe fill rows that
TOasked for, while a non-finiteSTEP, or aTObound the fill runs away from,returned the rows unfilled. Pass a finite value instead, or omit it.
Workflow [PR]
Sync PR [sync-upstream/pr/118434]
Version info
26.10.1.956-master(included in26.10and later)