Repository navigation
Make DateTime a portable logical type with a precision - #41550
ahmedabu98 wants to merge 2 commits into
Conversation
Java's DateTime now takes a precision (0 to 9, default 6) and is the standard beam:logical_type:datetime:v1 type, so SqlTypes.DATETIME is DateTime(6). Python gets a matching apache_beam.utils.timestamp.DateTime that converts to and from datetime.datetime and Arrow timestamps.
There was a problem hiding this comment.
📋 Review Summary
This PR promotes beam:logical_type:datetime:v1 to a standard portable logical type parameterized by subsecond precision (0–9, defaulting to 6) across the model proto, Java SDK, and Python SDK. The implementation is clean, well-structured, and thoroughly tested—including backward-compatibility handling for Java-serialized DateTime instances, legacy empty-string proto arguments, standard coder YAML test cases, and conversions between Python DateTime, datetime.datetime/pandas.Timestamp, and pyarrow.TimestampScalar.
🔍 General Feedback
- The precision validation, lossless/lossy conversion semantics, and representation invariants (
ROW<Date: INT64, Time: INT64>withTimein nanoseconds) are consistent between Java and Python. - Backward compatibility with older SDK encodings (both Java object serialization via
readResolveand legacy protoSTRING ""arguments in Python) is well covered by unit tests.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41550 +/- ##
============================================
+ Coverage 59.38% 59.41% +0.03%
Complexity 5133 5133
============================================
Files 1469 1469
Lines 187488 187668 +180
Branches 3816 3816
============================================
+ Hits 111342 111507 +165
- Misses 72741 72756 +15
Partials 3405 3405
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: @tvalentyn for label python. This pull request likely touches a core component ("core" label). Please review with scrutiny. 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). |
|
Reminder, please take a look at this pr: @tvalentyn |
Makes
beam:logical_type:datetime:v1a standard portable logical type with a precision (0 to 9, default 6). In Java,SqlTypes.DATETIMEbecomesDateTime(6), so aLocalDateTimewith sub-microsecond digits now throws (DateTime.NANOSkeeps them). Python gets a matchingapache_beam.utils.timestamp.DateTime.The Python
DateTimehas no arithmetic for now. To compute with it, convert it todatetime.datetimewithto_datetime()or to Arrow withto_arrow().This takes a similar approach to logical Timestamp (#36705, #39537). Design: https://s.apache.org/beam-timestamp-strategy