Skip to content

Commit 100a43b

Browse files
authored
Merge branch 'main' into interval_support
2 parents e8b918a + e62f5ab commit 100a43b

File tree

53 files changed

+1044
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1044
-521
lines changed

benchmarks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>com.google.cloud</groupId>
2626
<artifactId>google-cloud-spanner-parent</artifactId>
27-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
27+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
2828
</parent>
2929

3030
<properties>

generation_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gapic_generator_version: 2.54.0
2-
googleapis_commitish: 554575ee8d01d277344ec704e0561e9abc7f57f3
2+
googleapis_commitish: 68b6376ca75f03094a65ec5bbbc868bd9f058ee3
33
libraries_bom_version: 26.55.0
44
libraries:
55
- api_shortname: spanner

google-cloud-spanner-bom/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.cloud</groupId>
55
<artifactId>google-cloud-spanner-bom</artifactId>
6-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
6+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
77
<packaging>pom</packaging>
88
<parent>
99
<groupId>com.google.cloud</groupId>
@@ -53,43 +53,43 @@
5353
<dependency>
5454
<groupId>com.google.cloud</groupId>
5555
<artifactId>google-cloud-spanner</artifactId>
56-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
56+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
5757
</dependency>
5858
<dependency>
5959
<groupId>com.google.cloud</groupId>
6060
<artifactId>google-cloud-spanner</artifactId>
6161
<type>test-jar</type>
62-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
62+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
6363
</dependency>
6464
<dependency>
6565
<groupId>com.google.api.grpc</groupId>
6666
<artifactId>grpc-google-cloud-spanner-v1</artifactId>
67-
<version>6.88.0</version><!-- {x-version-update:grpc-google-cloud-spanner-v1:current} -->
67+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-v1:current} -->
6868
</dependency>
6969
<dependency>
7070
<groupId>com.google.api.grpc</groupId>
7171
<artifactId>grpc-google-cloud-spanner-admin-instance-v1</artifactId>
72-
<version>6.88.0</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-instance-v1:current} -->
72+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-instance-v1:current} -->
7373
</dependency>
7474
<dependency>
7575
<groupId>com.google.api.grpc</groupId>
7676
<artifactId>grpc-google-cloud-spanner-admin-database-v1</artifactId>
77-
<version>6.88.0</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-database-v1:current} -->
77+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-spanner-admin-database-v1:current} -->
7878
</dependency>
7979
<dependency>
8080
<groupId>com.google.api.grpc</groupId>
8181
<artifactId>proto-google-cloud-spanner-admin-instance-v1</artifactId>
82-
<version>6.88.0</version><!-- {x-version-update:proto-google-cloud-spanner-admin-instance-v1:current} -->
82+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-admin-instance-v1:current} -->
8383
</dependency>
8484
<dependency>
8585
<groupId>com.google.api.grpc</groupId>
8686
<artifactId>proto-google-cloud-spanner-v1</artifactId>
87-
<version>6.88.0</version><!-- {x-version-update:proto-google-cloud-spanner-v1:current} -->
87+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-v1:current} -->
8888
</dependency>
8989
<dependency>
9090
<groupId>com.google.api.grpc</groupId>
9191
<artifactId>proto-google-cloud-spanner-admin-database-v1</artifactId>
92-
<version>6.88.0</version><!-- {x-version-update:proto-google-cloud-spanner-admin-database-v1:current} -->
92+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-spanner-admin-database-v1:current} -->
9393
</dependency>
9494
</dependencies>
9595
</dependencyManagement>

google-cloud-spanner-executor/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.google.cloud</groupId>
77
<artifactId>google-cloud-spanner-executor</artifactId>
8-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner-executor:current} -->
8+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner-executor:current} -->
99
<packaging>jar</packaging>
1010
<name>Google Cloud Spanner Executor</name>
1111

1212
<parent>
1313
<groupId>com.google.cloud</groupId>
1414
<artifactId>google-cloud-spanner-parent</artifactId>
15-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
15+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
1616
</parent>
1717

1818
<properties>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,16 @@
880880
<className>com/google/cloud/spanner/SpannerOptions$SpannerEnvironment</className>
881881
<method>com.google.auth.oauth2.GoogleCredentials getDefaultExperimentalHostCredentials()</method>
882882
</difference>
883+
<difference>
884+
<differenceType>7002</differenceType>
885+
<className>com/google/cloud/spanner/SpannerOptions$SpannerEnvironment</className>
886+
<method>com.google.auth.oauth2.GoogleCredentials getDefaultExternalHostCredentials()</method>
887+
</difference>
888+
<difference>
889+
<differenceType>7002</differenceType>
890+
<className>com/google/cloud/spanner/SpannerOptions</className>
891+
<method>com.google.auth.oauth2.GoogleCredentials getDefaultExternalHostCredentialsFromSysEnv()</method>
892+
</difference>
883893

884894
<!-- Default sequence kind -->
885895
<difference>

google-cloud-spanner/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.cloud</groupId>
55
<artifactId>google-cloud-spanner</artifactId>
6-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
6+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
77
<packaging>jar</packaging>
88
<name>Google Cloud Spanner</name>
99
<url>https://github.com/googleapis/java-spanner</url>
1010
<description>Java idiomatic client for Google Cloud Spanner.</description>
1111
<parent>
1212
<groupId>com.google.cloud</groupId>
1313
<artifactId>google-cloud-spanner-parent</artifactId>
14-
<version>6.88.0</version><!-- {x-version-update:google-cloud-spanner:current} -->
14+
<version>6.88.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-spanner:current} -->
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-spanner</site.installationModule>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
*/
2727
abstract class AbstractMultiplexedSessionDatabaseClient implements DatabaseClient {
2828

29-
@Override
30-
public Dialect getDialect() {
31-
throw new UnsupportedOperationException();
32-
}
33-
3429
@Override
3530
public String getDatabaseRole() {
3631
throw new UnsupportedOperationException();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ private ResultSet executeQueryInternal(
641641
* <li>Specific {@link QueryOptions} passed in for this query.
642642
* <li>Any value specified in a valid environment variable when the {@link SpannerOptions}
643643
* instance was created.
644-
* <li>The default {@link SpannerOptions#getDefaultQueryOptions()} specified for the database
645-
* where the query is executed.
644+
* <li>The default {@link SpannerOptions#getDefaultQueryOptions(DatabaseId)} ()} specified for
645+
* the database where the query is executed.
646646
* </ol>
647647
*/
648648
@VisibleForTesting

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.cloud.spanner.Options.TransactionOption;
2323
import com.google.cloud.spanner.Options.UpdateOption;
2424
import com.google.spanner.v1.BatchWriteResponse;
25+
import com.google.spanner.v1.TransactionOptions.IsolationLevel;
2526

2627
/**
2728
* Interface for all the APIs that are used to read/write data into a Cloud Spanner database. An
@@ -414,6 +415,7 @@ ServerStream<BatchWriteResponse> batchWriteAtLeastOnce(
414415
* applied to any other requests on the transaction.
415416
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
416417
* {@link CommitResponse}.
418+
* <li>{@link Options#isolationLevel(IsolationLevel)}: The isolation level for the transaction
417419
* </ul>
418420
*/
419421
TransactionRunner readWriteTransaction(TransactionOption... options);
@@ -454,6 +456,7 @@ ServerStream<BatchWriteResponse> batchWriteAtLeastOnce(
454456
* applied to any other requests on the transaction.
455457
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
456458
* {@link CommitResponse}.
459+
* <li>{@link Options#isolationLevel(IsolationLevel)}: The isolation level for the transaction
457460
* </ul>
458461
*/
459462
TransactionManager transactionManager(TransactionOption... options);
@@ -494,6 +497,7 @@ ServerStream<BatchWriteResponse> batchWriteAtLeastOnce(
494497
* applied to any other requests on the transaction.
495498
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
496499
* {@link CommitResponse}.
500+
* <li>{@link Options#isolationLevel(IsolationLevel)}: The isolation level for the transaction
497501
* </ul>
498502
*/
499503
AsyncRunner runAsync(TransactionOption... options);
@@ -548,6 +552,7 @@ ServerStream<BatchWriteResponse> batchWriteAtLeastOnce(
548552
* applied to any other requests on the transaction.
549553
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
550554
* {@link CommitResponse}.
555+
* <li>{@link Options#isolationLevel(IsolationLevel)}: The isolation level for the transaction
551556
* </ul>
552557
*/
553558
AsyncTransactionManager transactionManagerAsync(TransactionOption... options);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ private boolean canUseMultiplexedSessionsForPartitionedOps() {
132132

133133
@Override
134134
public Dialect getDialect() {
135+
MultiplexedSessionDatabaseClient client = getMultiplexedSessionDatabaseClient();
136+
if (client != null) {
137+
return client.getDialect();
138+
}
135139
return pool.getDialect();
136140
}
137141

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class GrpcStreamIterator extends AbstractIterator<PartialResultSet>
5252
private TimeUnit streamWaitTimeoutUnit;
5353
private long streamWaitTimeoutValue;
5454
private SpannerException error;
55+
private boolean done;
5556

5657
@VisibleForTesting
5758
GrpcStreamIterator(int prefetchChunks, boolean cancelQueryWhenClientIsClosed) {
@@ -166,11 +167,17 @@ private class ConsumerImpl implements SpannerRpc.ResultStreamConsumer {
166167
@Override
167168
public void onPartialResultSet(PartialResultSet results) {
168169
addToStream(results);
170+
if (results.getLast()) {
171+
done = true;
172+
addToStream(END_OF_STREAM);
173+
}
169174
}
170175

171176
@Override
172177
public void onCompleted() {
173-
addToStream(END_OF_STREAM);
178+
if (!done) {
179+
addToStream(END_OF_STREAM);
180+
}
174181
}
175182

176183
@Override

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ public void onSessionReady(SessionImpl session) {
277277
.getSkipVerifyBeginTransactionForMuxRW()) {
278278
verifyBeginTransactionWithRWOnMultiplexedSessionAsync(session.getName());
279279
}
280+
if (sessionClient
281+
.getSpanner()
282+
.getOptions()
283+
.getSessionPoolOptions()
284+
.isAutoDetectDialect()) {
285+
MAINTAINER_SERVICE.submit(() -> getDialect());
286+
}
280287
}
281288

282289
@Override
@@ -513,6 +520,30 @@ private int getSingleUseChannelHint() {
513520
}
514521
}
515522

523+
private final AbstractLazyInitializer<Dialect> dialectSupplier =
524+
new AbstractLazyInitializer<Dialect>() {
525+
@Override
526+
protected Dialect initialize() {
527+
try (ResultSet dialectResultSet =
528+
singleUse().executeQuery(SessionPool.DETERMINE_DIALECT_STATEMENT)) {
529+
if (dialectResultSet.next()) {
530+
return Dialect.fromName(dialectResultSet.getString(0));
531+
}
532+
}
533+
// This should not really happen, but it is the safest fallback value.
534+
return Dialect.GOOGLE_STANDARD_SQL;
535+
}
536+
};
537+
538+
@Override
539+
public Dialect getDialect() {
540+
try {
541+
return dialectSupplier.get();
542+
} catch (Exception exception) {
543+
throw SpannerExceptionFactory.asSpannerException(exception);
544+
}
545+
}
546+
516547
@Override
517548
public Timestamp write(Iterable<Mutation> mutations) throws SpannerException {
518549
return createMultiplexedSessionTransaction(/* singleUse = */ false).write(mutations);

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.spanner.v1.ReadRequest.LockHint;
2222
import com.google.spanner.v1.ReadRequest.OrderBy;
2323
import com.google.spanner.v1.RequestOptions.Priority;
24+
import com.google.spanner.v1.TransactionOptions.IsolationLevel;
2425
import java.io.Serializable;
2526
import java.time.Duration;
2627
import java.util.Objects;
@@ -159,6 +160,13 @@ public static TransactionOption optimisticLock() {
159160
return OPTIMISTIC_LOCK_OPTION;
160161
}
161162

163+
/**
164+
* Specifying this instructs the transaction to request {@link IsolationLevel} from the backend.
165+
*/
166+
public static TransactionOption isolationLevel(IsolationLevel isolationLevel) {
167+
return new IsolationLevelOption(isolationLevel);
168+
}
169+
162170
/**
163171
* Specifying this instructs the transaction to be excluded from being recorded in change streams
164172
* with the DDL option `allow_txn_exclusion=true`. This does not exclude the transaction from
@@ -490,6 +498,20 @@ void appendToOptions(Options options) {
490498
}
491499
}
492500

501+
/** Option to set isolation level for read/write transactions. */
502+
static final class IsolationLevelOption extends InternalOption implements TransactionOption {
503+
private final IsolationLevel isolationLevel;
504+
505+
public IsolationLevelOption(IsolationLevel isolationLevel) {
506+
this.isolationLevel = isolationLevel;
507+
}
508+
509+
@Override
510+
void appendToOptions(Options options) {
511+
options.isolationLevel = isolationLevel;
512+
}
513+
}
514+
493515
private boolean withCommitStats;
494516

495517
private Duration maxCommitDelay;
@@ -512,6 +534,7 @@ void appendToOptions(Options options) {
512534
private RpcOrderBy orderBy;
513535
private RpcLockHint lockHint;
514536
private Boolean lastStatement;
537+
private IsolationLevel isolationLevel;
515538

516539
// Construction is via factory methods below.
517540
private Options() {}
@@ -664,6 +687,10 @@ LockHint lockHint() {
664687
return lockHint == null ? null : lockHint.proto;
665688
}
666689

690+
IsolationLevel isolationLevel() {
691+
return isolationLevel;
692+
}
693+
667694
@Override
668695
public String toString() {
669696
StringBuilder b = new StringBuilder();
@@ -726,6 +753,9 @@ public String toString() {
726753
if (lockHint != null) {
727754
b.append("lockHint: ").append(lockHint).append(' ');
728755
}
756+
if (isolationLevel != null) {
757+
b.append("isolationLevel: ").append(isolationLevel).append(' ');
758+
}
729759
return b.toString();
730760
}
731761

@@ -767,7 +797,8 @@ public boolean equals(Object o) {
767797
&& Objects.equals(directedReadOptions(), that.directedReadOptions())
768798
&& Objects.equals(orderBy(), that.orderBy())
769799
&& Objects.equals(isLastStatement(), that.isLastStatement())
770-
&& Objects.equals(lockHint(), that.lockHint());
800+
&& Objects.equals(lockHint(), that.lockHint())
801+
&& Objects.equals(isolationLevel(), that.isolationLevel());
771802
}
772803

773804
@Override
@@ -833,6 +864,9 @@ public int hashCode() {
833864
if (lockHint != null) {
834865
result = 31 * result + lockHint.hashCode();
835866
}
867+
if (isolationLevel != null) {
868+
result = 31 * result + isolationLevel.hashCode();
869+
}
836870
return result;
837871
}
838872

0 commit comments

Comments
 (0)