Repository navigation
Add support for zoneinfo UTC timestamps - #40613
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR updates Timestamp.from_utc_datetime to accept datetime.datetime objects with zoneinfo.ZoneInfo("UTC") in addition to pytz.utc and datetime.timezone.utc, addressing PyArrow 19+ timestamp conversion compatibility.
🔍 General Feedback
- The logic and unit test addition directly address the
zoneinfo.ZoneInfo("UTC")compatibility requirement. - Consider checking the
ZoneInfoinstance and its.keyattribute (or guarding againstZoneInfoNotFoundError) instead of instantiatingzoneinfo.ZoneInfo("UTC")during validation, so environments without OS-level tzdata or thetzdatapackage (e.g., Windows without optional dependencies) do not raiseZoneInfoNotFoundErrorwhen validating non-UTCtzinfoobjects.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40613 +/- ##
=============================================
+ Coverage 56.16% 79.90% +23.73%
=============================================
Files 1124 488 -636
Lines 178336 82428 -95908
Branches 1489 0 -1489
=============================================
- Hits 100170 65861 -34309
+ Misses 75645 16567 -59078
+ Partials 2521 0 -2521
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @claudevdm for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
When upgrading the Dataflow Templates Beam version in GoogleCloudPlatform/DataflowTemplates#4430 a small timestamp bug was surfaced: PyArrow 25+ returns timestamp data with the zone specified as zoneinfo.ZoneInfo('UTC') rather than the pytz representation. This standard was introduced as part of PEP 615 and has existed in every Python release since 3.9. A small fix was introduced in the templates PR to unblock that version upgrade, this fixes the bug in the Beam repo properly.