-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix Coalesce casting logic to follows what Postgres and DuckDB do. Introduce signature that do non-comparison coercion
#10268
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
c79156f
remove casting for coalesce
jayzhan211 a36e6b2
add more test
jayzhan211 bf16c92
add more test
jayzhan211 407e3c7
crate only visibility
jayzhan211 03b9162
polish comment
jayzhan211 4abf29d
improve test
jayzhan211 4965e8d
backup
jayzhan211 81f0235
introduce new signautre for coalesce
jayzhan211 bae996c
cleanup
jayzhan211 ddf9b1c
cleanup
jayzhan211 c2799ea
ignore err msg
jayzhan211 2574896
fmt
jayzhan211 6a17e57
fix doc
jayzhan211 4cba8c5
cleanup
jayzhan211 f1cfb8d
add more test
jayzhan211 d2e83d3
switch to type_resolution coercion
jayzhan211 3a88ad7
Merge remote-tracking branch 'upstream/main' into fix-coelesce
jayzhan211 03880a3
fix i64 and u64 case
jayzhan211 481f548
add more tests
jayzhan211 dfc4176
cleanup
jayzhan211 46a9060
add null case
jayzhan211 d656645
fmt
jayzhan211 5683447
fix
jayzhan211 b949fae
rename to type_union_resolution
jayzhan211 5aaeb5b
add comment
jayzhan211 a968c0e
Merge remote-tracking branch 'upstream/main' into fix-coelesce
jayzhan211 cf679c5
Merge remote-tracking branch 'upstream/main' into fix-coelesce
jayzhan211 15471ab
cleanup
jayzhan211 e5cc46b
fix test
jayzhan211 a810e85
add comment
jayzhan211 cb16cda
rm test
jayzhan211 53bedda
Merge remote-tracking branch 'upstream/main' into fix-coelesce
jayzhan211 a37da2d
cleanup since rebase
jayzhan211 70239e0
add more test
jayzhan211 be116f8
add more test
jayzhan211 8f4e991
fix msg
jayzhan211 6a8fe6f
Merge remote-tracking branch 'upstream/main' into fix-coelesce
jayzhan211 20e618e
Merge remote-tracking branch 'upstream/main' into fix-coelesce
jayzhan211 4153593
fmt
jayzhan211 030a519
rm pure_string_coercion
jayzhan211 5b797d5
rm duplicate
jayzhan211 b954479
change type in select.slt
jayzhan211 829b5a2
fix slt
jayzhan211 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ignore err msg
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
- Loading branch information
commit c2799ead9e93f36a6464708ea17adf806fd4b2b4
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1178,14 +1178,26 @@ select coalesce(null, null); | |
| ---- | ||
| NULL | ||
|
|
||
| # cast to float | ||
| query RT | ||
| select | ||
| coalesce(1, 2.0), | ||
| arrow_typeof(coalesce(1, 2.0)) | ||
| ; | ||
| ---- | ||
| 1 Float64 | ||
|
|
||
| query RT | ||
| select | ||
| coalesce(1, arrow_cast(2.0, 'Float32')), | ||
| arrow_typeof(coalesce(1, arrow_cast(2.0, 'Float32'))) | ||
| ; | ||
| ---- | ||
| 1 Float32 | ||
|
|
||
| # test with empty args | ||
| query error | ||
| select coalesce(); | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce()'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
|
|
||
| # test with different types | ||
| query I | ||
|
|
@@ -1271,14 +1283,12 @@ test | |
| statement ok | ||
| create table test1 as values (arrow_cast('foo', 'Dictionary(Int32, Utf8)')), (null); | ||
|
|
||
| # test coercion string | ||
| # Dictionary and String are not coercible | ||
| query error | ||
| select coalesce(column1, 'none_set') from test1; | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce(Dictionary(Int32, Utf8), Utf8)'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
| query error | ||
| select coalesce(null, column1, 'none_set') from test1; | ||
|
|
||
| # explicit cast to Utf8 | ||
| query T | ||
|
|
@@ -1287,14 +1297,18 @@ select coalesce(arrow_cast(column1, 'Utf8'), 'none_set') from test1; | |
| foo | ||
| none_set | ||
|
|
||
| # test coercion Int | ||
| statement ok | ||
| drop table test1 | ||
|
|
||
| # Numeric and Dictionary are not coercible | ||
|
||
| query error | ||
| select coalesce(34, arrow_cast(123, 'Dictionary(Int32, Int8)')); | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce(Int64, Dictionary(Int32, Int8))'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
| query error | ||
| select coalesce(arrow_cast(123, 'Dictionary(Int32, Int8)'), 34); | ||
|
|
||
| query error | ||
| select coalesce(null, 34, arrow_cast(123, 'Dictionary(Int32, Int8)')); | ||
|
|
||
| # explicit cast to Int8, and it will implicitly cast to Int64 | ||
| query IT | ||
|
|
@@ -1304,37 +1318,6 @@ select | |
| ---- | ||
| 123 Int64 | ||
|
|
||
| # test with Int | ||
| query error | ||
| select coalesce(arrow_cast(123, 'Dictionary(Int32, Int8)'), 34); | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce(Dictionary(Int32, Int8), Int64)'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
|
|
||
| # test with null | ||
| query error | ||
| select coalesce(null, 34, arrow_cast(123, 'Dictionary(Int32, Int8)')); | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce(Null, Int64, Dictionary(Int32, Int8))'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
|
|
||
| # test with null | ||
| query error | ||
| select coalesce(null, column1, 'none_set') from test1; | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce(Null, Dictionary(Int32, Utf8), Utf8)'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
|
|
||
| statement ok | ||
| drop table test1 | ||
|
|
||
|
|
||
| statement ok | ||
| CREATE TABLE test( | ||
| c1 INT, | ||
|
|
@@ -1356,14 +1339,9 @@ SELECT COALESCE(c1, c2) FROM test | |
| 1 | ||
| NULL | ||
|
|
||
| # coalesce result with default value | ||
| # int and string are not coercible | ||
| query error | ||
| SELECT COALESCE(c1, c2, '-1') FROM test | ||
| ---- | ||
| DataFusion error: Error during planning: No function matches the given name and argument types 'coalesce(Int32, Int32, Utf8)'. You might need to add explicit type casts. | ||
| Candidate functions: | ||
| coalesce(CoercibleT or NULL, .., CoercibleT or NULL) | ||
|
|
||
| SELECT COALESCE(c1, c2, '-1') FROM test; | ||
|
|
||
| statement ok | ||
| drop table test | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This query actually works on main so making it error seems like a regression to me