Decimal type support for to_timestamp #15486
Merged
alamb merged 5 commits intoapache:mainfrom Mar 31, 2025
Merged
Conversation
to_timestamp
alamb
reviewed
Mar 30, 2025
| 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; |
Contributor
There was a problem hiding this comment.
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?
Suggested change
| 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)
Contributor
Author
There was a problem hiding this comment.
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
approved these changes
Mar 30, 2025
nirnayroy
pushed a commit
to nirnayroy/datafusion
that referenced
this pull request
May 2, 2025
* 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
Member
|
Any reason datafusion/datafusion/functions/src/datetime/to_timestamp.rs Lines 333 to 352 in 00132da |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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