FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: introduce `java.time` methods and variables by diegomarquezp · Pull Request #2780 · googleapis/java-bigquerystorage · GitHub

This repository was archived by the owner on Feb 24, 2026. It is now read-only.

feat: introduce java.time methods and variables - #2780

Merged
gcf-merge-on-green[bot] merged 7 commits into
mainfrom
introduce-java-time
Dec 5, 2024
Merged

feat: introduce java.time methods and variables#2780
gcf-merge-on-green[bot] merged 7 commits into
mainfrom
introduce-java-time

Conversation

Copy link
Copy Markdown
Contributor

This PR introduces java.time alternatives to existing org.threeten.bp.* methods, as well as switching internal variables (if any) to java.time

The main constraint is to keep the changes backwards compatible, so for each existing threeten method "method1(org.threeten.bp.Duration)" we will add an alternative with a Duration (or Timestamp when applicable) suffix: "method1Duration(java.time.Duration)".

For most cases, the implementation will be held in the java.time method and the old threeten method will just delegate the call to it. However, for the case of abstract classes, the implementation will be kept in the threeten method to avoid breaking changes (i.e. users that already overloaded the method in their user code).

product-auto-label Bot added size: l Pull request size is large. api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API. labels Nov 20, 2024

diegomarquezp commented Nov 22, 2024
edited
Loading

Copy link
Copy Markdown
Contributor Author

@lqiu96 This check (java 8 only) is failing with

Error:    JsonToProtoMessageTest.testTimestampRepeated:890 expected:<test_string_repeated: 10
test_string_t_z_repeated: 1648493279010000
test_long_repeated: 1687984085000000
test_int_repeated: 153480695
test_float_repeated: [15346](https://github.com/googleapis/java-bigquerystorage/actions/runs/11942130315/job/33288467778?pr=2780#step:6:15347)8069500
test_offset_repeated: 1649135171000000
test_timezone_repeated: 1649174771000000
test_saformat_repeated: 1534680660000000
> but was:<test_string_repeated: 10
test_string_t_z_repeated: 1648493279010000
test_long_repeated: 1687984085000000
test_int_repeated: [15348](https://github.com/googleapis/java-bigquerystorage/actions/runs/11942130315/job/33288467778?pr=2780#step:6:15349)0695
test_float_repeated: 153468069500
test_offset_repeated: 1649149571000000
test_timezone_repeated: 1649174771000000
test_saformat_repeated: 1534680660000000
>

The problem is with test_offset_repeated; it's the same as googleapis/sdk-platform-java#3330 (comment), but the difference here is that we use appendOffset() with a default zone string of +00:00, while the one in appendZoneOrOffsetId() is Z

.optionalStart()
.appendOffset("+HH:MM", "+00:00")
.optionalEnd()
.optionalStart()
.appendZoneText(TextStyle.SHORT)
.optionalEnd()
.optionalStart()
.appendLiteral('Z')

diegomarquezp marked this pull request as ready for review November 22, 2024 18:41
diegomarquezp requested review from a team, hongalex and lqiu96 November 22, 2024 18:41
Comment on lines 93 to 102
.appendLiteral(' ')
.optionalEnd()
.optionalStart()
.appendOffset("+HH:MM", "+00:00")
.appendZoneOrOffsetId()
.optionalEnd()
.optionalStart()
.appendZoneText(TextStyle.SHORT)
.optionalEnd()
.optionalStart()
.appendLiteral('Z')
.optionalEnd()
.toFormatter()
.withZone(ZoneOffset.UTC);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This fix works for the current tests. Note that the literal Z is dropped from the config because appendZoneOrOffsetId() uses Z as the no-zone string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Added a test for +00:00 in 260c835


package com.google.cloud.bigquery.storage.util;

public class TimeConversionUtils {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why is this added in BQStorage and not used from sdk-platform-java?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

They are functions only used in BQS so far (confirmed other repos don't need them). However, the reason is simply because it's faster to implement here than waiting for a new release of gax with the utilities we have here. What if we follow up in gax and temporarily have these functions in this repo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What if we follow up in gax and temporarily have these functions in this repo?

Sure. Can we make this class package-private until we migrate this to Gax? Can you also create an issue in sdk-platform-java for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

As discussed internally, left as @InternalApi, referencing the new issue in sdk-platform: https://github.com/googleapis/sdk-platform-java/issues/3412

<to>java.time.Duration</to>
</difference>
<difference>
<!--The retryDelay field is used by ApiResultRetryAlgorithm, which is marked as @InternalApi-->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Errors$IsRetryableStatusResult is still marked as public even if it's only used by ApiResultRetryAlgorithm in the BQStorage SDK. I think it's still accessible which is problematic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@PhongChuong what's the rationale of Errors$IsRetryableStatusResult being public? Is it similar to the case of ApiResultRetryAlgorithm "visible for technical reasons"?
Also, does it make sense to change their datatypes directly, without threeten alternatives as done currently?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't know the historical reason as to why it is public but from the code, I would assume that is it "visible for technical reasons". Specifically, while IsRetryableStatusResult is public, it seems to be only used in ApiResultRetryAlgorithm and it is not part of the return value. I think it would be okay to change the datatype directly here.

@yirutang , what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am fine making it private. I don't think external user should use it.

diegomarquezp requested a review from lqiu96 November 27, 2024 22:31
PhongChuong self-requested a review November 28, 2024 11:01

PhongChuong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Overall the changes looks good. Thank you for the PR, it looks like a lot of work tracking down all the changes needed.

<to>java.time.Duration</to>
</difference>
<difference>
<!--The retryDelay field is used by ApiResultRetryAlgorithm, which is marked as @InternalApi-->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't know the historical reason as to why it is public but from the code, I would assume that is it "visible for technical reasons". Specifically, while IsRetryableStatusResult is public, it seems to be only used in ApiResultRetryAlgorithm and it is not part of the return value. I think it would be okay to change the datatype directly here.

@yirutang , what do you think?

lqiu96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Added a small comment if you could address

diegomarquezp added the automerge Merge the pull request once unit tests and other checks pass. label Dec 4, 2024
gcf-merge-on-green Bot merged commit 8dd66d5 into main Dec 5, 2024
gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Dec 5, 2024
gcf-merge-on-green Bot deleted the introduce-java-time branch December 5, 2024 02:10
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL