Skip to content

Commit

Permalink
add args len check
Browse files Browse the repository at this point in the history
  • Loading branch information
Syleechan committed Nov 21, 2023
1 parent f3abde6 commit b5286fa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions datafusion/physical-expr/src/unicode_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,13 @@ pub fn translate<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
/// SUBSTRING_INDEX('www.apache.org', '.', -2) = apache.org
/// SUBSTRING_INDEX('www.apache.org', '.', -1) = org
pub fn substr_index<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
if args.len() != 3 {
return Err(DataFusionError::Internal(format!(
"substr_index function requires three arguments, got {}",
args.len()
)));
}

let string_array = as_generic_string_array::<T>(&args[0])?;
let delimiter_array = as_generic_string_array::<T>(&args[1])?;
let count_array = as_int64_array(&args[2])?;
Expand Down

0 comments on commit b5286fa

Please sign in to comment.