Improve error message when string functions receive Binary types#19819
Improve error message when string functions receive Binary types#19819alamb merged 4 commits intoapache:mainfrom
Conversation
|
The fix is prepared, I am not sure if this would be a reasonable change tbh tho. Maybe just setting config is fine? |
|
Personally I'm not sure about this approach as it might suggest all other string functions with similar signature should now be fixed to also ensure they coerce from binary 🤔 e.g. datafusion/datafusion/functions/src/string/ascii.rs Lines 63 to 74 in 0808f3a datafusion/datafusion/functions/src/string/btrim.rs Lines 80 to 98 in 0808f3a datafusion/datafusion/functions/src/string/contains.rs Lines 59 to 71 in 0808f3a |
|
I guess ClickHouse does coerce them? So is this just a case of our semantics != ClickHouse? |
It's a similar problem to how Spark will coerce strings to ints for their math functions but we don't.
|
|
replace.rs uses Same for:
and maybe more. |
The problem is only with the ClickHouse https://datafusion.apache.org/user-guide/configs.html
So TLDR I don't think we need to make Instead I propose:
|
|
Thank you for working on this @lemorage Did you find out what was causing the internal error? I would expect the query would error with a normal error (about not supporting binary columns) |
This is related to |
9d88bfb to
62d712e
Compare
split_part function|
Thanks folks! Have updated the PR to improve the error msg better instead. |
| ; | ||
|
|
||
| # errors | ||
| query error DataFusion error: Error during planning: Internal error: Expect TypeSignatureClass::Binary but received NativeType::Int64, DataType: Int64 |
There was a problem hiding this comment.
👍 for a planning error rather than internal error
| select make_time(22, 1, ''); | ||
|
|
||
| query error Expect TypeSignatureClass::Native\(LogicalType\(Native\(Int32\), Int32\)\) but received NativeType::Float64, DataType: Float64 | ||
| query error DataFusion error: Error during planning: Function 'make_time' requires TypeSignatureClass::Native\(LogicalType\(Native\(Int32\), Int32\)\), but received Float64 \(DataType: Float64\) |
There was a problem hiding this comment.
I think these messages are much nicer -- thank you @lemorage
|
Thanks again @lemorage |
|
@alamb Thanks! And also all the discussions through! ❤️ |
…che#19819) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Related to apache#19004 and apache#19809. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Change internal error to user-facing error when function type coercion fails. Add helpful hint when Binary types are used with string functions. Before: ``` Internal error: Expect TypeSignatureClass::Native(...) but received NativeType::Binary, DataType: Binary ``` After: ``` Error: Function 'split_part' requires String, but received Binary (DataType: Binary). Hint: Binary types are not automatically coerced to String. Use CAST(column AS VARCHAR) to convert Binary data to String. ```
Which issue does this PR close?
What changes are included in this PR?
Change internal error to user-facing error when function type coercion fails. Add helpful hint when Binary types are used with string functions.
Before:
After: