Skip to content

Commit 62d712e

Browse files
committed
fix: improve error message for type coercion failures
1 parent 7b0ed2d commit 62d712e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

datafusion/expr/src/type_coercion/functions.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,13 @@ fn get_valid_types(
635635
default_casted_type.default_cast_for(current_type)?;
636636
new_types.push(casted_type);
637637
} else {
638-
return internal_err!(
639-
"Expect {} but received NativeType::{}, DataType: {}",
638+
let hint = if matches!(current_native_type, NativeType::Binary) {
639+
"\n\nHint: Binary types are not automatically coerced to String. Use CAST(column AS VARCHAR) to convert Binary data to String."
640+
} else {
641+
""
642+
};
643+
return plan_err!(
644+
"Function '{function_name}' requires {}, but received {} (DataType: {}).{hint}",
640645
param.desired_type(),
641646
current_native_type,
642647
current_type

0 commit comments

Comments
 (0)