-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Decimal type support for to_timestamp
#15486
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
Decimal type support for to_timestamp
#15486
Conversation
to_timestamp
alamb
left a comment
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.
Thanks @jatin510 -- very cool.
I have a question about the tests but otherwise this one looks good to go to me
| 1970-01-01T00:00:01.100 1970-01-01T00:00:01.100 1970-01-01T00:00:01.100 | ||
|
|
||
| query PPP | ||
| SELECT to_timestamp(arrow_cast(-1.1, 'Decimal128(2,1)')) as c1, cast(arrow_cast(-1.1, 'Decimal128(2,1)') as timestamp) as c2, arrow_cast(-1.1, 'Decimal128(2,1)')::timestamp as c3; |
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.
what is the value of computing the same value 3 times?
Perhaps it would make more sense to use different types with the same value to show the timestamp that comes back is the same and consistent?
| SELECT to_timestamp(arrow_cast(-1.1, 'Decimal128(2,1)')) as c1, cast(arrow_cast(-1.1, 'Decimal128(2,1)') as timestamp) as c2, arrow_cast(-1.1, 'Decimal128(2,1)')::timestamp as c3; | |
| SELECT to_timestamp(arrow_cast(-1.1, 'Int64')) as c1, cast(arrow_cast(-1.1, 'Decimal128(2,1)') as timestamp) as c2, arrow_cast(-1.1, 'Decimal128(9,8)')::timestamp as c3; |
(and similarly for the other tests)
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.
I took reference from other tests, and what i can check is that it shows different way of executing to_timestamp
to_timestamp(value)uses the UDF (User Defined Function) implementation in to_timestamp.rsCAST(value AS TIMESTAMP)or equivalently valueAS TIMESTAMPuses DataFusion's casting system which relies on Arrow's cast kernelsvalue::TIMESTAMPis SQL syntax sugar for CAST, and uses the same casting route as option 2
alamb
left a comment
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.
Thank you @jatin510
* wip: decimal type support for to_timestamp * updated timestamp handling for cast operator * fixed clippy error * fixed fmt * updated timestamps.slt file for decimal128 type support
|
Any reason datafusion/datafusion/functions/src/datetime/to_timestamp.rs Lines 333 to 352 in 00132da
|
Which issue does this PR close?
Rationale for this change
While working on this:
#14612
I found out that, when we enable
parse_float_as_decimalastrue.to_timestampandas timestampare converted into Decimal128 type.So, creating a separate PR, which can help us support
Decimaltype fortimestampas well.What changes are included in this PR?
Adding support for Decimal128 for timestamps
Are these changes tested?
Yes, Updated test in
timestamps.sltAre there any user-facing changes?
No