feat: Add from_datetime method to Timestamp types#9345
Open
codephage2020 wants to merge 2 commits intoapache:mainfrom
Open
feat: Add from_datetime method to Timestamp types#9345codephage2020 wants to merge 2 commits intoapache:mainfrom
codephage2020 wants to merge 2 commits intoapache:mainfrom
Conversation
6a39b1c to
617a44d
Compare
sdf-jkl
reviewed
Feb 4, 2026
sdf-jkl
reviewed
Feb 4, 2026
Contributor
sdf-jkl
left a comment
There was a problem hiding this comment.
Everything LGTM, but one comment below
Contributor
Author
alamb
reviewed
Feb 7, 2026
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thanks @codephage2020 and @sdf-jkl -- this looks great to me, except for one question (on returning Option). Let me know what you think
fbc7500 to
6b743f2
Compare
…tampType (apache#9337) Add two new methods to the ArrowTimestampType trait: - from_datetime: creates a timestamp from a timezone-aware DateTime<Tz> - from_naive_datetime: creates a timestamp from a NaiveDateTime with optional timezone This simplifies the conversion path from DateTime<Tz> to i64 timestamp, avoiding the need to manually call .naive_utc() + make_value(). Both methods return Option<i64> to safely handle overflow (e.g. nanosecond precision with extreme datetime values). Uses checked arithmetic consistent with existing make_value implementations. Includes tests for UTC, fixed-offset, subsecond precision, DST ambiguity, non-existent local times, and overflow boundaries.
6b743f2 to
63a4939
Compare
Contributor
Author
sdf-jkl
reviewed
Feb 10, 2026
alamb
approved these changes
Feb 11, 2026
Contributor
alamb
left a comment
There was a problem hiding this comment.
This looks good to me -- thank you so much @codephage2020 and @sdf-jkl
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?
DateTime#9337Rationale for this change
What changes are included in this PR?
Are these changes tested?
YES
Are there any user-facing changes?
YES, Now it is possible to directly convert from datatime to timestamp.