← Back to Pull requests

fix(spark): report INVALID_EXTRACT_FIELD for date_part #429

Open
unknown opened this pull request with 269 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 27, 2026 15:07 UTC
Author

Which issue does this PR close?

Related to #375.

What changes are included in this PR?

Add Spark's INVALID_EXTRACT_FIELD error 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 covers date_part, datepart and EXTRACT.

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 example t.d + 1 where Spark prints date_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_part fields now include Spark's error class and readable source context through SQL planning as well as direct physical invocation.

Diff: 269 lines (+201 / -68) across 3 files Reviewer: andygrove Review duration: 6003m
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
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
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
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% 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: 39.4% (MEDIUM) · Higher = larger blast radius
39.4%
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: 46.7% · Lower = rushed or shallow review
46.7%
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: 21% · Safe to merge
21%