fix: report make_date Date32 overflow in both ANSI modes #7343
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.46) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 456 lines diff across 5 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
Diff Size
diff_size
0.366
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7343"
general
weight: 0.35
sunchao
Which issue does this PR close?
Closes #6741. Final part of the split of #7117, following #7260, #7261, and #7283.
Rationale for this change
make_date(6000000, 1, 1)is a valid Java calendar date, but its epoch day exceeds Date32. Spark raisesARITHMETIC_OVERFLOWin both ANSI modes. Comet currently loses the overflow distinction and returns NULL with ANSI disabled or reports an invalid calendar date with ANSI enabled.What changes are included in this PR?
Separate calendar validation from checked Date32 conversion and propagate overflow through the existing typed Spark error path. Invalid calendar fields retain their ANSI-dependent behavior, including Java's year limits; NULL arguments still skip validation.
Preserve partial consumption through external row iterators, including PySpark
DataFrame.rddand preplanned DataFrames. Potentially throwing root projections use Spark; safe ANSI-off projections and date wrappers, materialized inputs, complete file writes, and a directLIMIT 1without OFFSET can remain native. Limits or filters inside a write retain their safeguards, and residual date filters retain the native Parquet reader. Larger root limits keep the safeguard because an RDD consumer can stop before the limit. The existing supported operator-fallback opt-out remains available.Keep
make_datepredicates above Parquet scans and disable sibling row filters for affected scans, preserving predicate order and structured Spark errors. Derive this guard from enclosing Spark filters and the original Catalyst predicates so it survives partition-column, nondeterministic, unsupported-expression, and unresolved-subquery filtering, including in Delta scans. Exclude each original predicate containingmake_datebefore partially rewriting metadata predicates, so rewriting cannot hide an overflow. Independent predicates retain metadata pruning according to Spark's Parquet settings, including type-specific opt-outs, safe AND/OR/NOT composition, and Spark's IN threshold. Apply the same settings when scalar-subquery filters are resolved at execution time.Add coverage for Date32 endpoints and adjacent overflow, calendar-error precedence, NULL and empty input, and overflowing rows skipped by LIMIT,
RDD.take, andmapPartitions. Document the overflow behavior.How are these changes tested?
Focused validation used JDK 17:
Validation before the latest Scala changes also passed 10 native
make_datetests, 28 native Parquet tests, 133 broader JVM tests, and 24 public PySparkDataFrame.rddcases with ANSI and AQE on/off. The native overflow regression, unsupported-OR predicate regression, and disabled-pushdown scalar-subquery regression each failed before their respective fixes.Expanded CI coverage still needs
run-spark-4.1-tests,run-all-spark-profiles, andrun-delta-testsbefore merging.