[Spark] Avoid file planning for unfiltered Delta V2 size statistics #7852
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
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
huan233usc
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: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.