Skip to content
Merged
Show file tree
Hide file tree
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
34 changes: 17 additions & 17 deletions datafusion/expr/src/built_in_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,25 +1395,25 @@ macro_rules! make_utf8_to_return_type {
DataType::LargeUtf8 => $largeUtf8Type,
DataType::Utf8 => $utf8Type,
DataType::Null => DataType::Null,
DataType::Dictionary(_, value_type) => {
match **value_type {
DataType::LargeUtf8 => $largeUtf8Type,
DataType::Utf8 => $utf8Type,
DataType::Null => DataType::Null,
_ => {
// this error is internal as `data_types` should have captured this.
return internal_err!(
"The {:?} function can only accept strings.",
name
);
}
DataType::Dictionary(_, value_type) => match **value_type {
DataType::LargeUtf8 => $largeUtf8Type,
DataType::Utf8 => $utf8Type,
DataType::Null => DataType::Null,
_ => {
// this error is internal as `data_types` should have captured this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment appears to be out of date. However, the code is good so I think we can merge this PR in as is. Thank you @Weijun-H

return plan_err!(
"The {:?} function can only accept strings, but got {:?}.",
name,
**value_type
);
}
}
_ => {
},
data_type => {
// this error is internal as `data_types` should have captured this.
return internal_err!(
"The {:?} function can only accept strings.",
name
return plan_err!(
"The {:?} function can only accept strings, but got {:?}.",
name,
data_type
);
}
})
Expand Down
6 changes: 6 additions & 0 deletions datafusion/sqllogictest/test_files/functions.slt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ SELECT substr('alphabet', 3, CAST(NULL AS int))
----
NULL

statement error The "substr" function can only accept strings, but got Int64.
SELECT substr(1, 3)

statement error The "substr" function can only accept strings, but got Int64.
SELECT substr(1, 3, 4)

query T
SELECT translate('12345', '143', 'ax')
----
Expand Down