← Back to Pull requests

[Spark] Avoid file planning for unfiltered Delta V2 size statistics #7852

Closed
unknown closed this pull request without merging on Oct 13, 2026 02:48 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 00:31 UTC
Author

Description

Spark's optimizer can request scan statistics (estimateSizeInBytes / estimateStatistics) before physical planning. Previously the Delta V2 scan always selected files to answer these requests, even for unfiltered scans where the result is already known.

For an unfiltered scan (no data filters, no partition filters, no pushed limit, not a CDC read), the snapshot checksum already records the exact size of every file the scan would select. The scan now returns that size directly before planning, so an early optimizer statistics request no longer triggers file selection. Physical planning stays lazy and still selects files exactly once.

Filtered, limit, and CDC scans continue to plan files so Spark receives their accurate post-pruning size. If the checksum does not record a table size, the scan falls back to planning rather than reporting an unknown size.

How was this patch tested?

Added tests to DeltaV2ScanTest:

  • Unfiltered scans report statistics without selecting files, and later physical planning selects files exactly once and reuses that selection.

  • Filtered scans and positive-limit scans plan files exactly once and reuse the selection for repeated statistics requests.

  • Tables written without checksums fall back to file planning for the size estimate.
  • Existing statistics tests were updated to reflect that full statistics for unfiltered scans now come from snapshot metadata.

    Does this PR introduce _any_ user-facing changes?

    No.

    Diff: 186 lines (+139 / -47) across 2 files Reviewer: huan233usc Review duration: 137m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.36) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 186 lines diff across 2 files
    0.36
    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.313
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #7852"
    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: 35.8% (MEDIUM) · Higher = larger blast radius
    35.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.5% · Safe to merge
    15.5%
    Repository