fix: array_slice and array_element panicked on empty args#10804
Merged
alamb merged 2 commits intoapache:mainfrom Jun 5, 2024
Merged
fix: array_slice and array_element panicked on empty args#10804alamb merged 2 commits intoapache:mainfrom
array_slice and array_element panicked on empty args#10804alamb merged 2 commits intoapache:mainfrom
Conversation
jayzhan211
reviewed
Jun 5, 2024
| [6.0] [6.0] [] [] | ||
|
|
||
| # Testing with empty arguments should result in an error | ||
| query error DataFusion error: Error during planning: Error during planning: \[data_types_with_scalar_udf\] signature VariadicAny does not support zero arguments. |
Contributor
There was a problem hiding this comment.
It is handled by signature!
alamb
reviewed
Jun 5, 2024
| fn display_name(&self, args: &[Expr]) -> Result<String> { | ||
| let args_name: Vec<String> = args.iter().map(|e| e.to_string()).collect(); | ||
| Ok(format!("{}[{}]", args_name[0], args_name[1])) | ||
| Ok(format!( |
Contributor
There was a problem hiding this comment.
that is a nice drive by cleanup
Contributor
|
Thanks @jonahgao and @jayzhan211 |
Member
Author
|
Thank you for the review @jayzhan211 @alamb |
findepi
pushed a commit
to findepi/datafusion
that referenced
this pull request
Jul 16, 2024
…#10804) * fix: `array_slice` and `array_element` panicked on empty args * Use single-line error
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?
Closes #10791.
Rationale for this change
When the
argsare empty, they panic at display_name, due to "index out of bounds".datafusion/datafusion/functions-array/src/extract.rs
Lines 253 to 256 in ece7ae5
The fix is to use an empty string as the arg name if it is out of bounds, allow
display_nameto pass through, and subsequently generating an error by checking the signature.What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No