fix: fall back for a window frame whose lower bound lies after its upper bound #7813
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 223 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.324
Real PR Conversation Timeline
1 comments
"Review active on #7813"
general
weight: 0.35
comphead
Which issue does this PR close?
Closes #7812.
Rationale for this change
Spark accepts a frame whose lower bound lies after its upper bound when one side is
CURRENT ROW(ROWS BETWEEN CURRENT ROW AND 2 PRECEDING,ROWS BETWEEN 2 FOLLOWING AND CURRENT ROW) and treats it as empty. Comet sends these ROWS frames to the native window operator, which gets a range withstart > endonce the offset is 2 or more. In a release build that returns a count of -1 and negated sums without an error, or fails the task, depending on the aggregate. Details and a repro are in the issue. With an offset of 1 the native range is empty, which matches Spark, and a reversed RANGE frame already falls back when its offset is serialized.A non-finite RANGE offset goes wrong too: a
NaNoffset, or an infinite offset over an infinite key (Infinity - Infinity), gives aNaNbound that the native range search does not compare the way Spark does.What changes are included in this PR?
CometWindowExec: fall back for a ROWS frame withCURRENT ROWon one side and an offset of 2 or more pointing past it, and for a RANGE frame with aNaNor infinite offset. The fallback reason spells the bounds as Spark's SQL does.operators.md.How are these changes tested?
sql-tests/windows/reversed_frame.sql: reversed ROWS frames in ASC and DESC order with NULL keys fall back and match Spark; offset 0 and 1 frames stay native; reversed RANGE frames over INT, DATE and TIMESTAMP keep their existing fallback;NaNand infinite RANGE offsets over a DOUBLE key with infinite values fall back in both directions. The fallback cases fail onmain.Generated-by: Claude Code (Claude Opus 5.5)
I reviewed the change and ran the tests myself.