Skip to content

Commit 6e220ff

Browse files
gagangupt16surbhigarg92diegomarquezpharshachintaolavloite
authored
chore: support for UUID type (#3572)
* feat: Add Metrics host for built in metrics (#3519) This PR allows users to set the custom monitoring host for built in metrics. * feat: introduce java.time variables and methods (#3495) 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). * chore(spanner): support multiplexed session for rw transactions in ex… (#3471) * chore(spanner): support multiplexed session for rw transactions in executor * chore(spanner): lint fix * chore: remove unused code and fix some warnings (#3533) * feat(spanner): support multiplexed session for Partitioned operations (#3231) * feat(spanner): support multiplexed session for Partitioned read or query. * chore(spanner): lint fixes * feat(spanner): support multiplexed session for Partitioned DML operations. * lint(spanner): javadoc fixes. * feat(spanner): Updated unit tests of Partitioned operations for Multiplexed Session. * feat(spanner): Updated unit tests of Partitioned operations for Multiplexed Session. * lint(spanner): Apply suggestions from code review Co-authored-by: Knut Olav Løite <[email protected]> * lint(spanner): Apply suggestions from code review Co-authored-by: Knut Olav Løite <[email protected]> * feat(spanner): Modified BatchClientImpl to store multiplexed session and create fresh session after expiration date. * feat(spanner): Removed env variable for Partitioned Ops ensuring that Multiplexed Session for Partitioned Ops is not available to customers. * lint(spanner): Removed unused variables. --------- Co-authored-by: Knut Olav Løite <[email protected]> * test: enable more tests on the Emulator (#3535) Multiple tests were skipped on the Emulator, because the features that are covered by these tests were originally not supported on the Emulator. These features are now available on the Emulator, and the tests can be enabled. * ci(spanner): Fix nightly job issues (#3522) * ci(spanner): Fix nightly job permission issue * update scope for surefire-junit4 * chore: add internal option for statement executor type (#3534) The Connection API by default uses either a platform thread or a virtual thread for each connection to execute and control the statements of that connection. This is used to enable asynchronous execution of statements and allows a statement to be cancelled by just interrupting this thread. Both these use cases are however not (or only very rarely) used by the most common users of the Connection API; the JDBC driver and PGAdapter. PGAdapter uses the PostgreSQL wire-protocol, which by design is synchronous, and JDBC is also a synchronous API. The latter has a cancel() method that currently requires this threading model, but this can be modified in the JDBC driver. Using a direct executor instead of a single-threaded executor per connection can save one thread per connection. The option is intentionally made package-private, so the above-mentioned frameworks can set it by default without it becoming part of the public API. * feat: support 'set local' for retry_aborts_internally (#3532) Adds support for `set local retry_aborts_internally=true|false` in the Connection API. This change also adds the parsing infrastructure that is needed to support `set local` for all connection variables. Support for this will be added to other connection variables in follow-up pull requests. * feat: add opt-in for using multiplexed sessions for blind writes (#3540) * feat(spanner): Releasing Multiplexed session for blind write. * fix(spanner): Added exception for `setUseMultiplexedSessionBlindWrite` in Clirr check. Removing this is safe as it's not used by customers. * fix(spanner): Fixed unit test for multiplexed session. * ci(spanner): clean up unused kokoro configurations (#3542) * ci(spanner): clean up unused kokoro configurations * chore: generate libraries at Tue Dec 10 09:54:10 UTC 2024 --------- Co-authored-by: cloud-java-bot <[email protected]> * test(spanner): Enabled multiplexed session for partitioned operations in systest. (#3545) * chore(main): release 6.82.1-SNAPSHOT (#3526) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * deps: update sdk platform java dependencies (#3549) * chore: reset default to platform thread (#3551) Reset the default to using a platform thread for connections. This was the default before adding an option for setting the executor type, and the new default is causing problems with the async Connection API. Fixes #3541 * chore: Update generation configuration at Fri Dec 13 16:21:35 UTC 2024 (#3523) * chore: Update generation configuration at Wed Dec 4 02:29:01 UTC 2024 * chore: Update generation configuration at Thu Dec 5 02:29:11 UTC 2024 * chore: Update generation configuration at Fri Dec 6 02:28:46 UTC 2024 * chore: generate libraries at Fri Dec 6 02:29:25 UTC 2024 * chore: Update generation configuration at Sat Dec 7 02:28:09 UTC 2024 * chore: Update generation configuration at Tue Dec 10 02:29:37 UTC 2024 * chore: Update generation configuration at Wed Dec 11 02:28:47 UTC 2024 * chore: Update generation configuration at Thu Dec 12 02:29:08 UTC 2024 * chore: generate libraries at Thu Dec 12 02:29:50 UTC 2024 * chore: Update generation configuration at Fri Dec 13 02:29:25 UTC 2024 * chore: Update generation configuration at Fri Dec 13 16:21:35 UTC 2024 * chore: generate libraries at Fri Dec 13 16:22:12 UTC 2024 * update workflow script --------- Co-authored-by: rahul2393 <[email protected]> Co-authored-by: Joe Wang <[email protected]> * chore(main): release 6.83.0 (#3547) * chore(main): release 6.83.0 * chore: generate libraries at Fri Dec 13 17:19:20 UTC 2024 --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: cloud-java-bot <[email protected]> * chore: make state field volatile in AsyncResultSetImpl (#3550) * chore: make state field volatile in AsyncResultSetImpl Mark the `state` field in `AsyncResultSetImpl` volatile, as it is inspected by different threads. * fix: protect writes with monitor --------- Co-authored-by: rahul2393 <[email protected]> * chore: make valid connection properties public (#3546) Make the list of valid connection properties public, so tools that depend on the Connection API can use this to for example generate documentation for valid properties. Also add valid values to the connection properties that have that (e.g. enums and booleans). Co-authored-by: rahul2393 <[email protected]> * deps: update opentelemetry.version to v1.45.0 (#3531) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [io.opentelemetry:opentelemetry-sdk-testing](https://redirect.github.com/open-telemetry/opentelemetry-java) | `1.44.1` -> `1.45.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.opentelemetry:opentelemetry-sdk-testing/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.opentelemetry:opentelemetry-sdk-testing/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.opentelemetry:opentelemetry-sdk-testing/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.opentelemetry:opentelemetry-sdk-testing/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.opentelemetry:opentelemetry-sdk-trace](https://redirect.github.com/open-telemetry/opentelemetry-java) | `1.44.1` -> `1.45.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.opentelemetry:opentelemetry-sdk-trace/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.opentelemetry:opentelemetry-sdk-trace/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.opentelemetry:opentelemetry-sdk-trace/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.opentelemetry:opentelemetry-sdk-trace/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.opentelemetry:opentelemetry-sdk-metrics](https://redirect.github.com/open-telemetry/opentelemetry-java) | `1.44.1` -> `1.45.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.opentelemetry:opentelemetry-sdk-metrics/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.opentelemetry:opentelemetry-sdk-metrics/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.opentelemetry:opentelemetry-sdk-metrics/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.opentelemetry:opentelemetry-sdk-metrics/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.opentelemetry:opentelemetry-sdk](https://redirect.github.com/open-telemetry/opentelemetry-java) | `1.44.1` -> `1.45.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.opentelemetry:opentelemetry-sdk/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.opentelemetry:opentelemetry-sdk/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.opentelemetry:opentelemetry-sdk/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.opentelemetry:opentelemetry-sdk/1.44.1/1.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>open-telemetry/opentelemetry-java (io.opentelemetry:opentelemetry-sdk-testing)</summary> ### [`v1.45.0`](https://redirect.github.com/open-telemetry/opentelemetry-java/blob/HEAD/CHANGELOG.md#Version-1450-2024-12-06) [Compare Source](https://redirect.github.com/open-telemetry/opentelemetry-java/compare/v1.44.1...v1.45.0) ##### API - Add convenience method `setAttribute(Attribute<Long>, int)` to SpanBuilder (matching the existing convenience method in Span) ([#&#8203;6884](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6884)) - Extends TextMapGetter with experimental GetAll() method, implement usage in W3CBaggagePropagator ([#&#8203;6852](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6852)) ##### SDK ##### Traces - Add synchronization to SimpleSpanProcessor to ensure thread-safe export of spans ([#&#8203;6885](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6885)) ##### Metrics - Lazily initialize ReservoirCells ([#&#8203;6851](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6851)) ##### Logs - Add synchronization to SimpleLogRecordProcessor to ensure thread-safe export of logs ([#&#8203;6885](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6885)) ##### Exporters - OTLP: Update opentelementry-proto to 1.4 ([#&#8203;6906](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6906)) - OTLP: Rename internal Marshaler#writeJsonToGenerator method to allow jackson runtimeOnly dependency ([#&#8203;6896](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6896)) - OTLP: Fix repeated string serialization for JSON. ([#&#8203;6888](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6888)) - OTLP: Fix missing unsafe available check ([#&#8203;6920](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6920)) ##### Extensions - Declarative config: Don't require empty objects when referencing custom components ([#&#8203;6891](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6891)) ##### Tooling - Add javadoc boilerplate internal comment v2 for experimental classes ([#&#8203;6886](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6886)) - Update develocity configuration ([#&#8203;6903](https://redirect.github.com/open-telemetry/opentelemetry-java/pull/6903)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/googleapis/java-spanner). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS40Mi40IiwidXBkYXRlZEluVmVyIjoiMzkuNTguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> * chore(main): release 6.83.1-SNAPSHOT (#3554) :robot: I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). * feat(spanner): add jdbc support for external hosts (#3536) * feat(spanner): add jdbc support for external hosts * feat(spanner): added default port value and unit tests * feat(spanner): fixed redundant class name typo * ci(spanner): improve performance of samples tests (#3558) * test: unflake RetryOnInvalidatedSessionTest (#3561) * ci(spanner): Create a new Sample Slow tests (#3560) * ci(spanner): Create a new Sample Slow tests * Fix delete backup issue in autogenerated admin client * chore: Update generation configuration at Sat Dec 14 02:27:24 UTC 2024 (#3555) Co-authored-by: rahul2393 <[email protected]> * test: enable write tests for PostgreSQL (#3529) * chore: include session min/max in error message (#3566) * fix: retry specific internal errors (#3565) * chore: make internal auth backend errors retryable Spanner occasionally returns INTERNAL errors regarding the auth backend server. These errors should be regarded as retryable. * fix: retry specific internal errors Some specific internal errors should be retrid. Instead of adding INTERNAL as a standard retryable error code, we use an interceptor to catch and translate those specific errors. See also b/375684610 * chore: address review comments * fix: wait for session pool to initialize * fix: register errors before creating the client * chore: disable native metrics when there are no credentials (#3567) * chore: disable native metrics when there are no credentials Native metrics were automatically disabled when the emulator is used, but some clients (e.g. PGAdapter) set up the connection to the emulator manually instead of setting the environment variable. Also, when using in-mem mock servers, native metrics should be disabled, as they cannot be exported. This PR therefore adds an additional check that disables native metrics when the client uses a NoCredentials instance. * chore: make method private * feat: add support for ARRAY<STRUCT> to CloudCilentExecutor (#3544) There are SPANNER_SYS tables that contain ARRAY<STRUCT> columns. Adding support for this in the CloudClientExecutor so that queries involving these tables do not throw an error. * chore: Update generation configuration at Wed Dec 18 05:50:09 UTC 2024 (#3564) * chore: Update generation configuration at Wed Dec 18 05:50:09 UTC 2024 * chore: generate libraries at Wed Dec 18 05:59:39 UTC 2024 * feat: support for UUID type * feat: support for UUID type * fix: unit tests for UUID type * fix: ignore uuid methods for clirr plugin * style: fix indentation * style: fix formatting issue * docs: added TODO for removing env checks for integration tests for UUID * fix: add missing return statement * refactor: use internal methods and remove unused code * fix: make it binary compatible while adding implementation for UUID methods in AbstractStructReader * style: formatting fix --------- Co-authored-by: surbhigarg92 <[email protected]> Co-authored-by: Diego Marquez <[email protected]> Co-authored-by: Sri Harsha CH <[email protected]> Co-authored-by: Knut Olav Løite <[email protected]> Co-authored-by: Pratick Chokhani <[email protected]> Co-authored-by: Sakthivel Subramanian <[email protected]> Co-authored-by: cloud-java-bot <[email protected]> Co-authored-by: Pratick Chokhani <[email protected]> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Mend Renovate <[email protected]> Co-authored-by: cloud-java-bot <[email protected]> Co-authored-by: rahul2393 <[email protected]> Co-authored-by: Joe Wang <[email protected]> Co-authored-by: Sagnik Ghosh <[email protected]> Co-authored-by: larkee <[email protected]> Co-authored-by: Gagan Gupta <[email protected]>
1 parent 4d956a9 commit 6e220ff

28 files changed

+1236
-19
lines changed

google-cloud-spanner/clirr-ignored-differences.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,38 @@
566566
<method>java.util.List getFloat32Array()</method>
567567
</difference>
568568

569+
<!-- UUID -->
570+
<difference>
571+
<differenceType>7012</differenceType>
572+
<className>com/google/cloud/spanner/StructReader</className>
573+
<method>java.util.UUID getUuid(int)</method>
574+
</difference>
575+
<difference>
576+
<differenceType>7012</differenceType>
577+
<className>com/google/cloud/spanner/StructReader</className>
578+
<method>java.util.UUID getUuid(java.lang.String)</method>
579+
</difference>
580+
<difference>
581+
<differenceType>7012</differenceType>
582+
<className>com/google/cloud/spanner/StructReader</className>
583+
<method>java.util.List getUuidList(int)</method>
584+
</difference>
585+
<difference>
586+
<differenceType>7012</differenceType>
587+
<className>com/google/cloud/spanner/StructReader</className>
588+
<method>java.util.List getUuidList(java.lang.String)</method>
589+
</difference>
590+
<difference>
591+
<differenceType>7013</differenceType>
592+
<className>com/google/cloud/spanner/Value</className>
593+
<method>java.util.UUID getUuid()</method>
594+
</difference>
595+
<difference>
596+
<differenceType>7013</differenceType>
597+
<className>com/google/cloud/spanner/Value</className>
598+
<method>java.util.List getUuidArray()</method>
599+
</difference>
600+
569601
<!-- INTERVAL -->
570602
<difference>
571603
<differenceType>7012</differenceType>

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractResultSet.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.Iterator;
3939
import java.util.List;
4040
import java.util.Objects;
41+
import java.util.UUID;
4142
import java.util.function.Function;
4243
import javax.annotation.Nonnull;
4344
import javax.annotation.Nullable;
@@ -434,6 +435,11 @@ protected Date getDateInternal(int columnIndex) {
434435
return currRow().getDateInternal(columnIndex);
435436
}
436437

438+
@Override
439+
protected UUID getUuidInternal(int columnIndex) {
440+
return currRow().getUuidInternal(columnIndex);
441+
}
442+
437443
@Override
438444
protected Interval getIntervalInternal(int columnIndex) {
439445
return currRow().getIntervalInternal(columnIndex);
@@ -531,6 +537,11 @@ protected List<Date> getDateListInternal(int columnIndex) {
531537
return currRow().getDateListInternal(columnIndex);
532538
}
533539

540+
@Override
541+
protected List<UUID> getUuidListInternal(int columnIndex) {
542+
return currRow().getUuidListInternal(columnIndex);
543+
}
544+
534545
@Override
535546
protected List<Interval> getIntervalListInternal(int columnIndex) {
536547
return currRow().getIntervalListInternal(columnIndex);

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractStructReader.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Arrays;
2929
import java.util.Collections;
3030
import java.util.List;
31+
import java.util.UUID;
3132
import java.util.function.Function;
3233

3334
/**
@@ -67,6 +68,10 @@ protected String getPgJsonbInternal(int columnIndex) {
6768

6869
protected abstract Date getDateInternal(int columnIndex);
6970

71+
protected UUID getUuidInternal(int columnIndex) {
72+
throw new UnsupportedOperationException("Not implemented");
73+
}
74+
7075
protected Interval getIntervalInternal(int columnIndex) {
7176
throw new UnsupportedOperationException("Not implemented");
7277
}
@@ -132,6 +137,10 @@ protected List<String> getPgJsonbListInternal(int columnIndex) {
132137

133138
protected abstract List<Date> getDateListInternal(int columnIndex);
134139

140+
protected List<UUID> getUuidListInternal(int columnIndex) {
141+
throw new UnsupportedOperationException("Not implemented");
142+
}
143+
135144
protected List<Interval> getIntervalListInternal(int columnIndex) {
136145
throw new UnsupportedOperationException("Not implemented");
137146
}
@@ -307,6 +316,19 @@ public Date getDate(String columnName) {
307316
return getDateInternal(columnIndex);
308317
}
309318

319+
@Override
320+
public UUID getUuid(int columnIndex) {
321+
checkNonNullOfType(columnIndex, Type.uuid(), columnIndex);
322+
return getUuidInternal(columnIndex);
323+
}
324+
325+
@Override
326+
public UUID getUuid(String columnName) {
327+
final int columnIndex = getColumnIndex(columnName);
328+
checkNonNullOfType(columnIndex, Type.uuid(), columnName);
329+
return getUuidInternal(columnIndex);
330+
}
331+
310332
@Override
311333
public Interval getInterval(int columnIndex) {
312334
checkNonNullOfType(columnIndex, Type.interval(), columnIndex);
@@ -604,6 +626,19 @@ public List<Date> getDateList(String columnName) {
604626
return getDateListInternal(columnIndex);
605627
}
606628

629+
@Override
630+
public List<UUID> getUuidList(int columnIndex) {
631+
checkNonNullOfType(columnIndex, Type.array(Type.uuid()), columnIndex);
632+
return getUuidListInternal(columnIndex);
633+
}
634+
635+
@Override
636+
public List<UUID> getUuidList(String columnName) {
637+
final int columnIndex = getColumnIndex(columnName);
638+
checkNonNullOfType(columnIndex, Type.array(Type.uuid()), columnName);
639+
return getUuidListInternal(columnIndex);
640+
}
641+
607642
@Override
608643
public List<Interval> getIntervalList(int columnIndex) {
609644
checkNonNullOfType(columnIndex, Type.array(Type.interval()), columnIndex);

google-cloud-spanner/src/main/java/com/google/cloud/spanner/ForwardingStructReader.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.protobuf.ProtocolMessageEnum;
2727
import java.math.BigDecimal;
2828
import java.util.List;
29+
import java.util.UUID;
2930
import java.util.function.Function;
3031

3132
/** Forwarding implements of StructReader */
@@ -231,6 +232,18 @@ public Date getDate(String columnName) {
231232
return delegate.get().getDate(columnName);
232233
}
233234

235+
@Override
236+
public UUID getUuid(int columnIndex) {
237+
checkValidState();
238+
return delegate.get().getUuid(columnIndex);
239+
}
240+
241+
@Override
242+
public UUID getUuid(String columnName) {
243+
checkValidState();
244+
return delegate.get().getUuid(columnName);
245+
}
246+
234247
@Override
235248
public Interval getInterval(int columnIndex) {
236249
checkValidState();
@@ -421,6 +434,18 @@ public List<Date> getDateList(String columnName) {
421434
return delegate.get().getDateList(columnName);
422435
}
423436

437+
@Override
438+
public List<UUID> getUuidList(int columnIndex) {
439+
checkValidState();
440+
return delegate.get().getUuidList(columnIndex);
441+
}
442+
443+
@Override
444+
public List<UUID> getUuidList(String columnName) {
445+
checkValidState();
446+
return delegate.get().getUuidList(columnName);
447+
}
448+
424449
@Override
425450
public List<Interval> getIntervalList(int columnIndex) {
426451
checkValidState();

google-cloud-spanner/src/main/java/com/google/cloud/spanner/GrpcStruct.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.Collections;
5050
import java.util.Iterator;
5151
import java.util.List;
52+
import java.util.UUID;
5253
import java.util.concurrent.atomic.AtomicBoolean;
5354
import java.util.function.Function;
5455
import java.util.stream.Collectors;
@@ -131,6 +132,9 @@ private Object writeReplace() {
131132
case DATE:
132133
builder.set(fieldName).to((Date) value);
133134
break;
135+
case UUID:
136+
builder.set(fieldName).to((UUID) value);
137+
break;
134138
case INTERVAL:
135139
builder.set(fieldName).to((Interval) value);
136140
break;
@@ -187,6 +191,9 @@ private Object writeReplace() {
187191
case DATE:
188192
builder.set(fieldName).toDateArray((Iterable<Date>) value);
189193
break;
194+
case UUID:
195+
builder.set(fieldName).toUuidArray((Iterable<UUID>) value);
196+
break;
190197
case INTERVAL:
191198
builder.set(fieldName).toIntervalArray((Iterable<Interval>) value);
192199
break;
@@ -304,6 +311,9 @@ private static Object decodeValue(Type fieldType, com.google.protobuf.Value prot
304311
case DATE:
305312
checkType(fieldType, proto, KindCase.STRING_VALUE);
306313
return Date.parseDate(proto.getStringValue());
314+
case UUID:
315+
checkType(fieldType, proto, KindCase.STRING_VALUE);
316+
return UUID.fromString(proto.getStringValue());
307317
case INTERVAL:
308318
checkType(fieldType, proto, KindCase.STRING_VALUE);
309319
return Interval.parseFromString(proto.getStringValue());
@@ -356,6 +366,7 @@ static Object decodeArrayValue(Type elementType, ListValue listValue) {
356366
case BYTES:
357367
case TIMESTAMP:
358368
case DATE:
369+
case UUID:
359370
case INTERVAL:
360371
case STRUCT:
361372
case PROTO:
@@ -513,6 +524,12 @@ protected Date getDateInternal(int columnIndex) {
513524
return (Date) rowData.get(columnIndex);
514525
}
515526

527+
@Override
528+
protected UUID getUuidInternal(int columnIndex) {
529+
ensureDecoded(columnIndex);
530+
return (UUID) rowData.get(columnIndex);
531+
}
532+
516533
@Override
517534
protected Interval getIntervalInternal(int columnIndex) {
518535
ensureDecoded(columnIndex);
@@ -640,6 +657,8 @@ protected Value getValueInternal(int columnIndex) {
640657
return Value.timestamp(isNull ? null : getTimestampInternal(columnIndex));
641658
case DATE:
642659
return Value.date(isNull ? null : getDateInternal(columnIndex));
660+
case UUID:
661+
return Value.uuid(isNull ? null : getUuidInternal(columnIndex));
643662
case INTERVAL:
644663
return Value.interval(isNull ? null : getIntervalInternal(columnIndex));
645664
case STRUCT:
@@ -682,6 +701,8 @@ protected Value getValueInternal(int columnIndex) {
682701
return Value.timestampArray(isNull ? null : getTimestampListInternal(columnIndex));
683702
case DATE:
684703
return Value.dateArray(isNull ? null : getDateListInternal(columnIndex));
704+
case UUID:
705+
return Value.uuidArray(isNull ? null : getUuidListInternal(columnIndex));
685706
case INTERVAL:
686707
return Value.intervalArray(isNull ? null : getIntervalListInternal(columnIndex));
687708
case STRUCT:
@@ -867,6 +888,13 @@ protected List<Date> getDateListInternal(int columnIndex) {
867888
return Collections.unmodifiableList((List<Date>) rowData.get(columnIndex));
868889
}
869890

891+
@Override
892+
@SuppressWarnings("unchecked") // We know ARRAY<UUID> produces a List<UUID>.
893+
protected List<UUID> getUuidListInternal(int columnIndex) {
894+
ensureDecoded(columnIndex);
895+
return Collections.unmodifiableList((List<UUID>) rowData.get(columnIndex));
896+
}
897+
870898
@Override
871899
@SuppressWarnings("unchecked") // We know ARRAY<Interval> produces a List<Interval>.
872900
protected List<Interval> getIntervalListInternal(int columnIndex) {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/ResultSets.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.spanner.v1.ResultSetStats;
3636
import java.math.BigDecimal;
3737
import java.util.List;
38+
import java.util.UUID;
3839
import java.util.function.Function;
3940

4041
/** Utility methods for working with {@link com.google.cloud.spanner.ResultSet}. */
@@ -326,6 +327,16 @@ public Date getDate(String columnName) {
326327
return getCurrentRowAsStruct().getDate(columnName);
327328
}
328329

330+
@Override
331+
public UUID getUuid(int columnIndex) {
332+
return getCurrentRowAsStruct().getUuid(columnIndex);
333+
}
334+
335+
@Override
336+
public UUID getUuid(String columnName) {
337+
return getCurrentRowAsStruct().getUuid(columnName);
338+
}
339+
329340
@Override
330341
public Interval getInterval(int columnIndex) {
331342
return getCurrentRowAsStruct().getInterval(columnIndex);
@@ -518,6 +529,16 @@ public List<Date> getDateList(String columnName) {
518529
return getCurrentRowAsStruct().getDateList(columnName);
519530
}
520531

532+
@Override
533+
public List<UUID> getUuidList(int columnIndex) {
534+
return getCurrentRowAsStruct().getUuidList(columnIndex);
535+
}
536+
537+
@Override
538+
public List<UUID> getUuidList(String columnName) {
539+
return getCurrentRowAsStruct().getUuidList(columnName);
540+
}
541+
521542
@Override
522543
public List<Interval> getIntervalList(int columnIndex) {
523544
return getCurrentRowAsStruct().getIntervalList(columnIndex);

google-cloud-spanner/src/main/java/com/google/cloud/spanner/Struct.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.ArrayList;
3737
import java.util.List;
3838
import java.util.Objects;
39+
import java.util.UUID;
3940
import java.util.function.Function;
4041
import javax.annotation.concurrent.Immutable;
4142

@@ -226,6 +227,11 @@ protected Date getDateInternal(int columnIndex) {
226227
return values.get(columnIndex).getDate();
227228
}
228229

230+
@Override
231+
protected UUID getUuidInternal(int columnIndex) {
232+
return values.get(columnIndex).getUuid();
233+
}
234+
229235
@Override
230236
protected Interval getIntervalInternal(int columnIndex) {
231237
return values.get(columnIndex).getInterval();
@@ -339,6 +345,11 @@ protected List<Date> getDateListInternal(int columnIndex) {
339345
return values.get(columnIndex).getDateArray();
340346
}
341347

348+
@Override
349+
protected List<UUID> getUuidListInternal(int columnIndex) {
350+
return values.get(columnIndex).getUuidArray();
351+
}
352+
342353
@Override
343354
protected List<Interval> getIntervalListInternal(int columnIndex) {
344355
return values.get(columnIndex).getIntervalArray();
@@ -430,6 +441,8 @@ private Object getAsObject(int columnIndex) {
430441
return getTimestampInternal(columnIndex);
431442
case DATE:
432443
return getDateInternal(columnIndex);
444+
case UUID:
445+
return getUuidInternal(columnIndex);
433446
case INTERVAL:
434447
return getIntervalInternal(columnIndex);
435448
case STRUCT:
@@ -463,6 +476,8 @@ private Object getAsObject(int columnIndex) {
463476
return getTimestampListInternal(columnIndex);
464477
case DATE:
465478
return getDateListInternal(columnIndex);
479+
case UUID:
480+
return getUuidListInternal(columnIndex);
466481
case INTERVAL:
467482
return getIntervalListInternal(columnIndex);
468483
case STRUCT:

0 commit comments

Comments
 (0)