You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "clairemcginty (via GitHub)" <gi...@apache.org> on 2025/02/24 22:26:37 UTC
[PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
clairemcginty opened a new pull request, #34059:
URL: https://github.com/apache/beam/pull/34059
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](https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowToStorageApiProto.java), [BeamRowToStorageApiProto](https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProto.java)) and noticed they were using this `CivilTimeEncoder` class to translate TIME types to Longs, whereas `AvroGenericRecordToStorageApiProto` 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:
- [ ] Mention the appropriate issue in your description (for example: `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, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "clairemcginty (via GitHub)" <gi...@apache.org>.
clairemcginty commented on code in PR #34059:
URL: https://github.com/apache/beam/pull/34059#discussion_r1968504722
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProtoTest.java:
##########
@@ -456,8 +464,8 @@ enum TestEnum {
.put("numericvalue", numericBytes)
.put("bignumericvalue", bigNumericBytes)
.put("datevalue", 42)
- .put("timemicrosvalue", 42_000_000L)
- .put("timemillisvalue", 42_000_000L)
+ .put("timemicrosvalue", CivilTimeEncoder.encodePacked64TimeMicros(localTime))
Review Comment:
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 😅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34059:
URL: https://github.com/apache/beam/pull/34059#issuecomment-2688858810
Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
R: @kennknowles for label java.
R: @shunping for label io.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34059:
URL: https://github.com/apache/beam/pull/34059#issuecomment-2680061085
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "clairemcginty (via GitHub)" <gi...@apache.org>.
clairemcginty commented on code in PR #34059:
URL: https://github.com/apache/beam/pull/34059#discussion_r1968504722
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProtoTest.java:
##########
@@ -456,8 +464,8 @@ enum TestEnum {
.put("numericvalue", numericBytes)
.put("bignumericvalue", bigNumericBytes)
.put("datevalue", 42)
- .put("timemicrosvalue", 42_000_000L)
- .put("timemillisvalue", 42_000_000L)
+ .put("timemicrosvalue", CivilTimeEncoder.encodePacked64TimeMicros(localTime))
Review Comment:
I was curious so I checked the difference here. CivilTimeEncoder translates this value to `44,040,192` compared to the original `42,000,000`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "clairemcginty (via GitHub)" <gi...@apache.org>.
clairemcginty commented on PR #34059:
URL: https://github.com/apache/beam/pull/34059#issuecomment-2688601945
ah forgot to mention, the format violations seemed to be in an unrelated file, but it looks like they were just fixed [here](https://github.com/apache/beam/pull/34092/commits/b7a4d72eb555d828a92a993d88647951a148e8be). Just rebased my PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on PR #34059:
URL: https://github.com/apache/beam/pull/34059#issuecomment-2688457046
Thanks for the fix! Could you please run './gradlew :sdks:java:io:google-cloud-platform:spotlessApply' then push a new commit to format code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] (fix #34038) Use CivilTimeEncoder to encode Time values in AvroGenericRecordToStorageApiProto [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #34059:
URL: https://github.com/apache/beam/pull/34059
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org