-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: Add implicit casting to TypeSignature::String
#13404
Conversation
Please remove the changes to regexp_match as that change adds in support for utf8view which breaks that function (see ci output). It's a much larger issue than those changes. See #11911 (comment) for some details. |
Will fix this tommorow. |
NULL | ||
|
||
query T | ||
SELECT ltrim(12345, '1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DuckDB doesn't allow this query 🤔
Numeric string casting is quite confusing to me
D SELECT ltrim(12345, '1');
Binder Error: No function matches the given name and argument types 'ltrim(INTEGER_LITERAL, STRING_LITERAL)'. You might need to add explicit type casts.
Candidate functions:
ltrim(VARCHAR) -> VARCHAR
ltrim(VARCHAR, VARCHAR) -> VARCHAR
LINE 1: SELECT ltrim(12345, '1');
Same with postgres
postgres=# SELECT ltrim(12345, '1');
ERROR: function ltrim(integer, unknown) does not exist
LINE 1: SELECT ltrim(12345, '1');
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Mark this as draft as it is not ready for review |
@alamb @jayzhan211 I'm a bit confused with this pr, are we looking to support implicit casting with TypeSignature or not? As can be seen above, this behaviour seems to have been deprecated in DuckDB. |
I think we still prefer the actual result in Postgres and DuckDB |
@jayzhan211 So should this PR be closed? Since there is no need for implicit casting in TypeSignature::String? I just worked on this because of your comment on implicit casting in #13301 |
Sure. |
I don't agree with the decision to not support implicit coercion to string for function arguments. Firstly, it's a regression from currently supported features and will break things for users, myself included. Secondly Postgresql's requirement for explicit casting for so many things imho is one of it's most annoying 'features' and is generally not required by just about every other database out there. The reasoning given for the DuckDB decision was nothing to do with functions and everything to do with casting issues with general sql and comparisons which I tend to agree with. See the PR for details.
should not be required.
should just work. |
For this reason alone I agree , and it would definitely fall into the category of implicit semantic changes causing troubles described on I don't fully understand the current state -- is there a regression between 43 and 44 (not yet released)? If so, is it tracked with a ticket? |
The regression I think was in 43 but I am not 100% sure. I just built 42 off the tag and ran it in docker: root@f93d03a93bc1:/apache_datafusion# docker run --rm -it datafusion-cli_42
DataFusion CLI v42.2.0
> select ascii(42);
+------------------+
| ascii(Int64(42)) |
+------------------+
| 52 |
+------------------+
1 row(s) fetched.
Elapsed 0.001 seconds.
The slt test I just added in main:
I suspect any function switched in #12751 will no longer work with any type coercion. Edit: just verified the above sql works with DF 41 as well. |
Which issue does this PR close?
Closes #.
Rationale for this change
#13402 #13394 were running into some problems with implicit casting due to TypeSignature::String not dealing with implicit casting properly
What changes are included in this PR?
Added implicit casting to TypeSignature::String
Are these changes tested?
Yes
Are there any user-facing changes?