-
Notifications
You must be signed in to change notification settings - Fork 4.4k
(fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto #34059
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
(fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto #34059
Conversation
.put("datevalue", 42) | ||
.put("timemicrosvalue", 42_000_000L) | ||
.put("timemillisvalue", 42_000_000L) | ||
.put("timemicrosvalue", CivilTimeEncoder.encodePacked64TimeMicros(localTime)) |
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 was curious so I checked the difference here. CivilTimeEncoder translates this value to 44,040,192
compared to the original 42,000,000
. I do not know why but doing a test write to BQ shows seemingly correct values now 😅
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
b2f0894
to
6fd52aa
Compare
Thanks for the fix! Could you please run './gradlew :sdks:java:io:google-cloud-platform:spotlessApply' then push a new commit to format code? |
…GenericRecordToStorageApiProto
6fd52aa
to
5b992a0
Compare
ah forgot to mention, the format violations seemed to be in an unrelated file, but it looks like they were just fixed here. Just rebased my PR! |
Assigning reviewers. If you would like to opt out of this review, comment R: @kennknowles for label java. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
…GenericRecordToStorageApiProto (apache#34059) * (fix apache#34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto * Update CHANGES * Don't throw away precision
I noticed that in Beam 2.63, TIME types were being encoded incorrectly when using the Storage Write API. For example, I'd try to write a value of 6:30 and it would get written to BQ as 5:28. See #34038.
I looked at what the other *ToStorageApiProto classes were doing (TableRowToStorageApiProto, BeamRowToStorageApiProto) and noticed they were using this
CivilTimeEncoder
class to translate TIME types to Longs, whereasAvroGenericRecordToStorageApiProto
was trying to compute manually from milliseconds/microseconds of day. It's a small difference but it accounts for the BQ discrepancies.I've tested this out locally when writing to BQ and the values look correct now, but I would definitely appreciate someone with more domain knowledge checking in! Also, looks should maybe be using this encoder for DATETIME types, too?
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.