← Back to Pull requests

fix: fall back for a window frame whose lower bound lies after its upper bound #7813

Open
unknown opened this pull request with 223 lines diff across 2 files
View on GitHub
unknown unknown commented on Dec 01, 2026 05:49 UTC
Author

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 with start > end once 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 NaN offset, or an infinite offset over an infinite key (Infinity - Infinity), gives a NaN bound 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 with CURRENT ROW on one side and an offset of 2 or more pointing past it, and for a RANGE frame with a NaN or infinite offset. The fallback reason spells the bounds as Spark's SQL does.

  • Two lines in the window section of 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; NaN and infinite RANGE offsets over a DOUBLE key with infinite values fall back in both directions. The fallback cases fail on main.

    Generated-by: Claude Code (Claude Opus 5.5)

    I reviewed the change and ran the tests myself.

    Diff: 223 lines (+167 / -56) across 2 files Reviewer: comphead Review duration: 2445m
    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
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21% · Safe to merge
    21%