fix(spark): report INVALID_EXTRACT_FIELD for date_part #429
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 269 lines diff across 3 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.335
Real PR Conversation Timeline
1 comments
"Review active on #429"
general
weight: 0.35
andygrove
Which issue does this PR close?
Related to #375.
What changes are included in this PR?
Add Spark's
INVALID_EXTRACT_FIELDerror class and include the available source expression, literal or column name in the error. SQL planning validates invalid literal fields before casts and column aliases lose their context. The same validation coversdate_part,datepartandEXTRACT.Date and timestamp literals, including casts of literals, use SQL-style value formatting. Direct physical calls format Date64, timezone-aware timestamps and strings without Rust Debug output. Argument-count checks also prevent malformed direct calls from indexing missing arguments.
Spark 4.2.0 includes outer double quotes around the source, so those are retained. Plain strings use their bare value. DataFusion represents typed SQL literals and explicit casts alike at this validation point, so casts intentionally keep the normalized date, timestamp or NULL value. PySpark 4.2.0 retains explicit
CAST(...)instead. These differences are documented beside the SQL records. Compound expressions retain DataFusion's readable notation (for examplet.d + 1where Spark printsdate_add(d, 1)), and direct physical calls do not receive the original SQL. This remains related to #375 rather than claiming exact source formatting for every SQL expression.Are these changes tested?
The invalid-field SQL records assert the full expected error, including the source and quoting, in both simplify and evaluate modes. Added coverage for cast literals, EXTRACT, direct scalar formatting and malformed argument lists.
Formatting and strict Clippy passed. All 607 Rust tests, 3 doctests and 518 SQL test runs passed (259 files in both modes). Eight source-formatting queries were checked against PySpark 4.2.0 with ANSI enabled and disabled. Added plain-string and compound-expression SQL coverage; the plain-string regression fails before the fix in both execution modes.
Are there any user-facing changes?
Invalid
date_partfields now include Spark's error class and readable source context through SQL planning as well as direct physical invocation.