fix(spark): return error from ELT coerce_types when fewer than 2 args#23164
Open
davidlghellin wants to merge 1 commit into
Open
fix(spark): return error from ELT coerce_types when fewer than 2 args#23164davidlghellin wants to merge 1 commit into
davidlghellin wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a planning-time validation bug in the Spark elt scalar UDF: when fewer than 2 arguments were provided, an error was constructed but never returned, allowing invalid arities to proceed.
Changes:
- Return the
plan_datafusion_err!result fromSparkElt::coerce_typeswhenarg_types.len() < 2, properly short-circuiting invalid calls.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
70
to
75
| let length = arg_types.len(); | ||
| if length < 2 { | ||
| plan_datafusion_err!( | ||
| return Err(plan_datafusion_err!( | ||
| "ELT function expects at least 2 arguments: index, value1" | ||
| ); | ||
| )); | ||
| } |
alamb
approved these changes
Jun 24, 2026
alamb
left a comment
Contributor
There was a problem hiding this comment.
Nice catch -- thank you @davidlghellin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
SparkElt::coerce_typesvalidates that ELT receives at least 2 arguments (index + value1), but the error was never returned: it was built withplan_datafusion_err!(...)as an expression statement whose value was discarded. SinceDataFusionErroris not#[must_use], the compiler didn't warn, so the function fell through and continued with fewer arguments than required instead of failing with a clear plan-time error.What changes are included in this PR?
In datafusion/spark/src/function/string/elt.rs, the argument-count check is wrapped in return Err(plan_datafusion_err!(...)) so the validation actually short-circuits when fewer than 2 arguments are provided.
Are these changes tested?
This change restores an error path that was previously dropped silently. ELT's normal behavior is already covered by the existing tests in elt.rs. The invalid-arity branch had no coverage because it was never actually exercised.
Are there any user-facing changes?
ELT now returns a plan-time error when invoked with fewer than 2 arguments, instead of silently continuing. No public API changes.