-
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
Add casting from arbitrary arrow types #5016
Comments
I think this is apretty good first issue as it is well specified and you can follow the model of arrow_typeof to add a new function and there is an arrow cast kernel that does all the data type conversions |
@alamb I'd like taking this |
Thanks @comphead ! |
It would be also interesting to support "custom" types in |
I was thinking we could use So I think we could make a int8 column in a table like
|
@alamb in parser we operate with expressions which works with arrow types. But for the potential |
It differs because normal casting
I don't think there is any analog in postgres; The difference is that you can refer to all types in postgres directly using SQL. Since posgres types are sql types there is no analog to this ticket's proposal in SQL |
@alamb please correct me if I'm wrong so
will have the same output as
|
@alamb sorry, haven't started it yet. made couple of drafts, but thats it. If this is a priority thing, please feel free to take this on |
I am starting to hack on this |
#5166 is now ready for review (I really want this function so I can more easily write / port tests and reproduce bugs) |
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
While porting some tests to sqllogictest I want t ensure the same coverage for specific types.
For example
https://github.com/apache/arrow-datafusion/blob/350cb47289a76e579b221fe374e4cf09db332569/datafusion/core/tests/sql/mod.rs#L1233
It is easy to cast to some SQL datatype:
However, it is not possible to use SQL to name certain arrow types (e.g TimestampMicrosecond
as
TIMESTAMP` maps to TimestampNanosI would like a way to convert an expression to an arbitrary arrow type.
Describe the solution you'd like
I would love to do something like
Where
target_type
is a string that describes an arrow tyoeFor example:
I would like the values accepted as 'target_datatype' to t same as returned by the
arrow_typeof()
function that goes the other direction (expression to string that represents Arrow type)Describe alternatives you've considered
It would be nice to have some way to specify Arrow types in SQL datatype syntax. Perhaps like
CAST X as CUSTOM TYPE 'Int64'
. This would allow using functions such astry_cast
, as well as creating tables with specific column types.However, I am not really sure how to do this in the parser
Additional context
See #4460 for more details
The text was updated successfully, but these errors were encountered: