Skip to content
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

Add coercion support for NULL literals #185

Closed
Tracked by #2355
alamb opened this issue Apr 26, 2021 · 2 comments
Closed
Tracked by #2355

Add coercion support for NULL literals #185

alamb opened this issue Apr 26, 2021 · 2 comments
Labels
datafusion Changes in the datafusion crate

Comments

@alamb
Copy link
Contributor

alamb commented Apr 26, 2021

Note: migrated from original JIRA: https://issues.apache.org/jira/browse/ARROW-11851

As we observed in apache/arrow#9565 (comment) datafusion won't coerce null literals, forcing strange syntax such as:

rpad('hi', CAST(NULL AS INT), 'xy')

We should add automatic coercion logic from the null literal to any type and this expression should work just fine (produce a NULL output)

rpad('hi', NULL, 'xy')

@alamb alamb added the datafusion Changes in the datafusion crate label Apr 26, 2021
@alamb
Copy link
Contributor Author

alamb commented Apr 26, 2021

Comment from Mike Seddon(MikeSeddonAU) @ 2021-03-03T21:52:10.241+0000:

[~alamb] Previously I implemented the Null=UTF8 type based on the behavior of Postgres not Spark - because the Spark implementation comes with a lot of side effects like the fact that Parquet does not support the `NullType`. We can revisit.

Comment from Andrew Lamb(alamb) @ 2021-03-04T19:29:54.556+0000:

Makes sense to me

@alamb
Copy link
Contributor Author

alamb commented Nov 14, 2022

This appears to work just fine now:

❯ select cast(null as int);
+------+
| NULL |
+------+
|      |
+------+
1 row in set. Query took 0.033 seconds.

🎉

@alamb alamb closed this as completed Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

No branches or pull requests

1 participant