Skip to content

Commit

Permalink
Remove redundant argument and improve error message (#12217)
Browse files Browse the repository at this point in the history
* Remove redundant argument and improve error message

* Update datafusion/functions/src/string/common.rs

Co-authored-by: Oleks V <comphead@users.noreply.github.com>

* Update datafusion/functions/src/string/common.rs

Co-authored-by: Oleks V <comphead@users.noreply.github.com>

---------

Co-authored-by: Oleks V <comphead@users.noreply.github.com>
  • Loading branch information
findepi and comphead authored Aug 30, 2024
1 parent e603185 commit 88dd305
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions datafusion/functions/src/string/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ pub(crate) fn general_trim<T: OffsetSizeTrait>(
};

if use_string_view {
string_view_trim::<T>(trim_type, func, args)
string_view_trim::<T>(func, args)
} else {
string_trim::<T>(trim_type, func, args)
string_trim::<T>(func, args)
}
}

// removing 'a will cause compiler complaining lifetime of `func`
fn string_view_trim<'a, T: OffsetSizeTrait>(
trim_type: TrimType,
func: fn(&'a str, &'a str) -> &'a str,
args: &'a [ArrayRef],
) -> Result<ArrayRef> {
Expand Down Expand Up @@ -129,14 +128,13 @@ fn string_view_trim<'a, T: OffsetSizeTrait>(
}
other => {
exec_err!(
"{trim_type} was called with {other} arguments. It requires at least 1 and at most 2."
"Function TRIM was called with {other} arguments. It requires at least 1 and at most 2."
)
}
}
}

fn string_trim<'a, T: OffsetSizeTrait>(
trim_type: TrimType,
func: fn(&'a str, &'a str) -> &'a str,
args: &'a [ArrayRef],
) -> Result<ArrayRef> {
Expand Down Expand Up @@ -183,7 +181,7 @@ fn string_trim<'a, T: OffsetSizeTrait>(
}
other => {
exec_err!(
"{trim_type} was called with {other} arguments. It requires at least 1 and at most 2."
"Function TRIM was called with {other} arguments. It requires at least 1 and at most 2."
)
}
}
Expand Down

0 comments on commit 88dd305

Please sign in to comment.