feat(spark): support optional and variadic arguments in SparkInputTypes #421
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 425 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.362
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #421"
general
weight: 0.35
andygrove
Which issue does this PR close?
Rationale for this change
SparkInputTypestakes exactly one type per argument, so a function with optional trailing arguments (round(expr[, scale])) or a variadic tail (concat_ws,elt) can't use it yet. #353 listseltandconcat_wsas waiting on this.What changes are included in this PR?
SparkInputTypes::optional(required, optional, volatility), soroundcan be declared as[Numeric]plus an optional[Integer].coercereturns types only for the arguments that were given, and the function supplies the default for an omitted one itself.SparkInputTypes::variadic(fixed, repeated, min_args, volatility): the fixed types, thenrepeatedfor every remaining argument, with a minimum total count. The fixed arguments are always required. An invalid argument in the tail is reported by its own position, like any other argument.WRONG_NUM_ARGStext for each case, formatted the wayQueryCompilationErrors.wrongNumArgsErrordoes it:2for one accepted count (unchanged),[1, 2]when several counts are accepted, and> 1/> 0for a variadic minimum, aseltandconcat_wsraise it.CONTRIBUTING.mdand the module docs pointing to the two new constructors.No function is moved onto them here, so there are no user-visible changes yet.
concat_wscan use these constructors as they stand.eltcan use the count check, but it still needs its own type checks (the index must already be INT, and every remaining argument must be STRING or BINARY), and check-only mode cannot yet be combined with a variadic tail. Moving the functions is left to #353.Are these changes tested?
Yes, with unit tests in
implicit_cast.rs:[1, 2]/[0, 1, 2, 3]messagesconcat_ws-shaped variadic declaration (casts across the tail, separator only, an invalid tail argument reported by position, and the> 0message), plus the> 1message foreltmin_argsis smaller, a variadic tail with no minimum, and ANSI mode applying to the tailI checked the expected messages against Spark 4.2.0:
wrongNumArgsError, the> 0check inConcatWs, the> 1check inElt, andto_json's[1, 2]in thejson-functions.sql.outgolden file. I didn't use the PySpark runner, since nothing reaches SQL yet.cargo fmt,cargo clippy --all-targets --all-features -- -D warnings,cargo test -p datafusion-spark,cargo test -p datafusion-spark-sqllogictestandcargo docall pass locally.Are there any user-facing changes?
No. The new constructors are crate-internal, and no function's behavior changes.