← Back to Pull requests

[spark] Pin the copy-on-write scan to the snapshot it was built on #11485

Closed
unknown closed this pull request without merging on Nov 29, 2026 02:19 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 02:30 UTC
Author

Purpose

Fixes #11484. Copy-on-write DELETE, UPDATE and MERGE INTO on Spark 3.5+ run Spark's runtime group filter, which tells PaimonCopyOnWriteScan which files hold matching rows. The scan then reloaded those files from the latest snapshot. If a commit such as a compaction replaced some of them in between, those files no longer matched, and the statement skipped their rows while reporting success.

The scan now reads the snapshot that was latest when Spark built it, so such a commit fails with "File deletion conflicts detected", as the V1 commands do. A selected file missing from that snapshot is accepted only if a later APPEND added it, or only the other branch of a scan.fallback-branch or scan.primary-branch table has it. Otherwise the scan asks for a retry. Later snapshots come from the catalog when it tracks them. With options such as scan.snapshot-id, any missing file fails the statement.

Tests

PaimonCopyOnWriteScanTest:

  • DELETE, UPDATE (also as a union plan) and MERGE INTO whose condition calls a UDF that commits a compaction from the group filter subquery: each fails with the conflict and leaves the table unchanged.

  • Files of a later compaction fail the scan, also after a rollback. Later appends are accepted, also next to a compaction elsewhere, with scan.file-creation-time-millis, and while the catalog runs ahead of the files.

  • Other-branch files are accepted after either branch rewrote its files and while its catalog runs ahead of its files. A file main regained by a rollback is rejected, also once compacted again, as are new files of an other branch rolled back past its snapshot.

  • A reused snapshot id, an expired snapshot, an empty table, the fallback row a DELETE keeps, and scan.snapshot-id.
  • Diff: 220 lines (+165 / -55) across 2 files Reviewer: LuciferYang Review duration: 2869m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 220 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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
    Diff Size diff_size
    0.323
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11485"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 15.9% · Safe to merge
    15.9%
    Repository