Skip to content
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

feat: add PG OID support #2736

Merged
merged 53 commits into from
Apr 5, 2024
Merged

feat: add PG OID support #2736

merged 53 commits into from
Apr 5, 2024

Conversation

tlhquynh
Copy link
Contributor

@tlhquynh tlhquynh commented Nov 20, 2023

Added support for PG OID type which is an int64 value with a PG_OID type annotation code.

@tlhquynh tlhquynh requested review from a team as code owners November 20, 2023 12:51
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: spanner Issues related to the googleapis/java-spanner API. labels Nov 20, 2023
olavloite added a commit that referenced this pull request Nov 21, 2023
Remove the example partition token from the SQL test scripts, as the
tokens are not stable when the encoded classes are changed. E.g.
modifying the Value classes will cause these tests to fail with a
de-serialization error, as the serialized version in the token no longer
corresponds with the version in code.

Fixes the build error in #2736
olavloite added a commit that referenced this pull request Nov 24, 2023
* test: remove partition token from tests

Remove the example partition token from the SQL test scripts, as the
tokens are not stable when the encoded classes are changed. E.g.
modifying the Value classes will cause these tests to fail with a
de-serialization error, as the serialized version in the token no longer
corresponds with the version in code.

Fixes the build error in #2736

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
@tlhquynh
Copy link
Contributor Author

Both aforementioned TODOs regarding class incompatible due to mismatched serialVersionUID and rebasing after #2703 is merged are done.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Mar 14, 2024
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Mar 19, 2024
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 22, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 22, 2024
@olavloite olavloite self-requested a review March 22, 2024 07:09
Copy link
Collaborator

@olavloite olavloite left a comment

Choose a reason for hiding this comment

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

Looks generally good to me. The biggest question that I have is whether there is any value in adding all the getPgOid(..) methods, or whether it would be better to just say 'use getLong(..) for both normal INT64 and PG.OID values'.

.java-version Outdated
@@ -0,0 +1 @@
17.0.9
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this file (and potentially add the file name to .gitignore to prevent it from being included in commits in the future)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,4 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above: Remove file from GitHub and add the filename to .gitignore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -61,6 +61,8 @@ protected String getPgJsonbInternal(int columnIndex) {
throw new UnsupportedOperationException("Not implemented");
}

protected abstract long getPgOidInternal(int columnIndex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a default implementation for this and the other methods that are being added to this class. The default implementation should just throw UnsupportedOperationException. This prevents this change from being a breaking change, as anyone who has a class that extends AbstractStructReader does not get a compile error.

That should also remove the requirement to add the method names to clirr-ignored-differences.xml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -192,6 +192,63 @@
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.List getPgJsonbList(java.lang.String)</method>
</difference>
<!-- PG OID -->
<difference>
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should not be necessary to add the internal methods to this file, if those methods are given a default implementation that just throws UnsupportedOperationException

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

These entries in clirr-ignored-differences.xml for StructReader can be removed, as we don't have those methods anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

final nit (I promise :-)): I think that the two remaining additions to this file for getPgOid() and getPgOidArray() can also be removed, as these methods are no longer added to the Value class.

Comment on lines 268 to 279
@Override
public long getPgOid(int columnIndex) {
checkNonNullOfType(columnIndex, Type.pgOid(), columnIndex);
return getPgOidInternal(columnIndex);
}

@Override
public long getPgOid(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfType(columnIndex, Type.pgOid(), columnName);
return getPgOidInternal(columnIndex);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be worth considering not adding any of this at all, and instead instruct users that they have to get PG.OID values in the same way as INT64? So just call getLong(..) and the other corresponding methods. This is otherwise all just a copy-paste of those methods, and there's no additional validation of the values that we are getting.
I know that it is not what we have done for other types (e.g. we could in theory have done the same for JSON by telling users to just call getString(...)). But this might be the right time to start to prevent us from doing double work for future types, while it does not add any additional type safety or features for users.

@skuruppu Any thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
I had an offline chat with @skuruppu and treating OID as Long is actually what we are doing for the other clients. I have removed all external PG.OID getters.

@@ -572,22 +613,40 @@ public void testInsertAllTypes() {
ExecuteSqlRequest request = mockSpanner.getRequestsOfType(ExecuteSqlRequest.class).get(0);
Map<String, Type> paramTypes = request.getParamTypesMap();
Map<String, Value> params = request.getParams().getFieldsMap();
assertEquals(20, paramTypes.size());
assertEquals(20, params.size());
System.out.println("Dialect = " + dialect);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

olavloite and others added 6 commits March 26, 2024 10:18
* chore: keep session pool ordering when pinging

Pinging sessions would move the sessions that were pinged to either the
front or the back of the pool (dependingin the session pool
configuration), instead of keeping the sessions in the place where they
were when being pinged. Bringing a session that is pinged to the front
of the pool means that we will prefer using a session that has not
really been used for a while, other than for the ping. Keeping the
sessions in place is therefore preferable.

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
To enable Direct Access, [both `setAttemptDirectPath` and `setAttemptDirectPathXds` should be called](https://togithub.com/googleapis/sdk-platform-java/blob/4b44a7851dc1d4fd2ac21a54df6c24db5625223c/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java#L373-L386) for gax to append the correct google-c2p scheme.

This PR adds a env var `GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS` to control the enable/disable of Direct Access. When it is true, it calls `setAttemptDirectPathXds` which effectively turns on Direct Access (as `options.isAttemptDirectPath` is by default true and we don't need to call `setAttemptDirectPath` again).
@@ -192,6 +192,63 @@
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.List getPgJsonbList(java.lang.String)</method>
</difference>
<!-- PG OID -->
<difference>
Copy link
Collaborator

Choose a reason for hiding this comment

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

These entries in clirr-ignored-differences.xml for StructReader can be removed, as we don't have those methods anymore.

@@ -61,6 +61,10 @@ protected String getPgJsonbInternal(int columnIndex) {
throw new UnsupportedOperationException("Not implemented");
}

protected long getPgOidInternal(int columnIndex) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that you can remove this method (and the equivalent array methods below) as well, and instead just use the getLongInternal method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

checkNonNullOfCodes(
columnIndex, Arrays.asList(Code.ENUM, Code.PG_OID, Code.INT64), columnIndex);
return getColumnType(columnIndex).getCode() == Code.PG_OID
? getPgOidInternal(columnIndex)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that this can be simplified to just calling getLongInternal. The same also applies to the array methods below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -460,6 +468,12 @@ protected String getPgJsonbInternal(int columnIndex) {
return (String) rowData.get(columnIndex);
}

@Override
protected long getPgOidInternal(int columnIndex) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove and rely on getLongInternal instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -771,6 +789,18 @@ protected List<String> getPgJsonbListInternal(int columnIndex) {
return Collections.unmodifiableList((List<String>) rowData.get(columnIndex));
}

@Override
protected Int64Array getPgOidListInternal(int columnIndex) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove and use getLongListInternal instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

arpan14 and others added 21 commits April 3, 2024 17:46
…ionFuture interfaces. (googleapis#2973)

* chore: add multiplexed session implementations for CachedSession/SessionFuture  interfaces.

* chore: add comments.

* chore: add session replacement handler for multiplexed session.

* chore: address comments.

* chore: fix comments.

* chore: fix comments.
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
…googleapis#2959)

* Add support for transaction-level exclusion from change streams

* cleanup

* refactor: introduce PartitionedUpdateOption

* Revert "refactor: introduce PartitionedUpdateOption"

This reverts commit 96b508b.

* Add error handling in DML update APIs where excludeTxnFromChangeStreams option is not applicable

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…3.40.0 (googleapis#2987)

* deps: update dependency com.google.cloud:google-cloud-monitoring to v3.40.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…35.0 (googleapis#2989)

* chore(deps): update dependency com.google.cloud:libraries-bom to v26.35.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
* chore: clean up some warnings and malformed comments

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…to v6.63.0 (googleapis#2992)

* chore(deps): update dependency com.google.cloud:google-cloud-spanner to v6.63.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Adds an 'endpoint' connection URL property for the Connection API.
This property can be used instead of adding the endpoint to the host
group part of the Connection URL, which again removes the need to
actually change the connection URL when connecting to for example
the emulator from the JDBC driver. The latter can instead just add
the endpoint to the Properties set that is given to the JDBC driver.
* feat: support max_commit_delay in Connection API

Adds support for max_commit_delay to the Connection API:
1. Adds a setMaxCommitDelay(Duration) method to Connection
2. Adds a maxCommitDelay connection URL property
3. Adds a SET MAX_COMMIT_DELAY=<duration> SQL statement

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore: minor improvements to default benchmarks.

* chore: lint issues fix.

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
googleapis#2971)

Source-Link: googleapis/synthtool@ca7a716
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:cecae6152a85d55c932a64515643cf2e32a1f1b6e17503080eb07744b2177f28

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
googleapis#2932)

* feat: Add instance partition support to spanner instance proto

PiperOrigin-RevId: 611127452

Source-Link: googleapis/googleapis@618d47c

Source-Link: googleapis/googleapis-gen@92d8555
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTJkODU1NTg4ODI4NDMwZThiNDI4ZWQ3ODIxOWUyM2VlNjY2ZGE3OCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix(deps): Update the Java code generator (gapic-generator-java) to 2.37.0

PiperOrigin-RevId: 611816371

Source-Link: googleapis/googleapis@2a40f63

Source-Link: googleapis/googleapis-gen@d30ff07
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDMwZmYwNzY3Nzc3YjM4MWZiMTYxN2Y2N2E5MGUzYWJkM2JkYzZkYyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Add SessionPoolOptions, SpannerOptions protos in executor protos

PiperOrigin-RevId: 621265883

Source-Link: googleapis/googleapis@fed9845

Source-Link: googleapis/googleapis-gen@c66a769
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzY2YTc2OTU3ZTJlMTYzNDdiYzFkZDNmNGM2MzgyMjNmMDY1ZWU4MCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
@@ -192,6 +192,63 @@
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.List getPgJsonbList(java.lang.String)</method>
</difference>
<!-- PG OID -->
<difference>
Copy link
Collaborator

Choose a reason for hiding this comment

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

final nit (I promise :-)): I think that the two remaining additions to this file for getPgOid() and getPgOidArray() can also be removed, as these methods are no longer added to the Value class.

@googleapis googleapis deleted a comment from generated-files-bot bot Apr 4, 2024
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 5, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 5, 2024
@thiagotnunes thiagotnunes merged commit ba2a4af into googleapis:main Apr 5, 2024
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants