Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant argument and improve error message #12217

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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