Skip to content

Commit 24b986b

Browse files
authored
fix: backend now supports optimizer version for DML (#252)
* fix: backend now supports optimizer version for DML * fix: update shared config to prevent build failures * fix: update shared config in samples * fix: upgrade spanner version in install-without-bom * fix: try with java11 * deps: ignore autovalue * deps: add auto-value dependency * fix: fix linting error and revert to Java8
1 parent 13e47c3 commit 24b986b

File tree

11 files changed

+80
-35
lines changed

11 files changed

+80
-35
lines changed

.kokoro/build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ test)
5151
RETURN_CODE=$?
5252
;;
5353
lint)
54-
mvn \
55-
-Penable-samples \
56-
com.coveo:fmt-maven-plugin:check
54+
mvn com.coveo:fmt-maven-plugin:check
5755
RETURN_CODE=$?
5856
;;
5957
javadoc)

google-cloud-spanner-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.google.cloud</groupId>
1010
<artifactId>google-cloud-shared-config</artifactId>
11-
<version>0.6.0</version>
11+
<version>0.7.0</version>
1212
</parent>
1313

1414
<name>Google Cloud Spanner BOM</name>

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryOptionsTest.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public void executeQuery() {
107107

108108
@Test
109109
public void executeUpdate() {
110-
// Query optimizer version is ignored for DML statements by the backend, but setting it does not
111-
// cause an error.
110+
// Optimizer version 1 should work.
112111
assertThat(
113112
client
114113
.readWriteTransaction()
@@ -150,35 +149,38 @@ public Long run(TransactionContext transaction) throws Exception {
150149
}))
151150
.isEqualTo(1L);
152151

153-
// Version '100000' is an invalid value, but is ignored by the backend.
154-
assertThat(
155-
client
156-
.readWriteTransaction()
157-
.run(
158-
new TransactionCallable<Long>() {
159-
@Override
160-
public Long run(TransactionContext transaction) throws Exception {
161-
return transaction.executeUpdate(
162-
Statement.newBuilder("INSERT INTO TEST (ID, NAME) VALUES (@id, @name)")
163-
.bind("id")
164-
.to(3L)
165-
.bind("name")
166-
.to("Three")
167-
.withQueryOptions(
168-
QueryOptions.newBuilder().setOptimizerVersion("10000").build())
169-
.build());
170-
}
171-
}))
172-
.isEqualTo(1L);
152+
// Version '100000' is an invalid value and should cause an error.
153+
try {
154+
client
155+
.readWriteTransaction()
156+
.run(
157+
new TransactionCallable<Long>() {
158+
@Override
159+
public Long run(TransactionContext transaction) throws Exception {
160+
return transaction.executeUpdate(
161+
Statement.newBuilder("INSERT INTO TEST (ID, NAME) VALUES (@id, @name)")
162+
.bind("id")
163+
.to(3L)
164+
.bind("name")
165+
.to("Three")
166+
.withQueryOptions(
167+
QueryOptions.newBuilder().setOptimizerVersion("100000").build())
168+
.build());
169+
}
170+
});
171+
fail("missing expected exception");
172+
} catch (SpannerException e) {
173+
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
174+
assertThat(e.getMessage()).contains("Query optimizer version: 100000 is not supported");
175+
}
173176

174-
// Verify that query options are ignored with Partitioned DML as well, and that all the above
175-
// DML INSERT statements succeeded.
177+
// Setting an optimizer version for PDML should also be allowed.
176178
assertThat(
177179
client.executePartitionedUpdate(
178180
Statement.newBuilder("UPDATE TEST SET NAME='updated' WHERE 1=1")
179181
.withQueryOptions(QueryOptions.newBuilder().setOptimizerVersion("1").build())
180182
.build()))
181-
.isEqualTo(3L);
183+
.isEqualTo(2L);
182184
}
183185

184186
@Test

grpc-google-cloud-spanner-admin-database-v1/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<groupId>com.google.guava</groupId>
3838
<artifactId>guava</artifactId>
3939
</dependency>
40+
<dependency>
41+
<groupId>com.google.auto.value</groupId>
42+
<artifactId>auto-value-annotations</artifactId>
43+
</dependency>
4044
<dependency>
4145
<groupId>com.google.api.grpc</groupId>
4246
<artifactId>proto-google-iam-v1</artifactId>
@@ -63,6 +67,17 @@
6367
</profiles>
6468

6569
<build>
70+
<pluginManagement>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-dependency-plugin</artifactId>
75+
<configuration>
76+
<ignoredDependencies>com.google.auto.value:auto-value-annotations</ignoredDependencies>
77+
</configuration>
78+
</plugin>
79+
</plugins>
80+
</pluginManagement>
6681
<plugins>
6782
<plugin>
6883
<?m2e ignore?>

grpc-google-cloud-spanner-admin-instance-v1/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<groupId>com.google.guava</groupId>
3838
<artifactId>guava</artifactId>
3939
</dependency>
40+
<dependency>
41+
<groupId>com.google.auto.value</groupId>
42+
<artifactId>auto-value-annotations</artifactId>
43+
</dependency>
4044
<dependency>
4145
<groupId>com.google.api.grpc</groupId>
4246
<artifactId>proto-google-iam-v1</artifactId>
@@ -63,6 +67,17 @@
6367
</profiles>
6468

6569
<build>
70+
<pluginManagement>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-dependency-plugin</artifactId>
75+
<configuration>
76+
<ignoredDependencies>com.google.auto.value:auto-value-annotations</ignoredDependencies>
77+
</configuration>
78+
</plugin>
79+
</plugins>
80+
</pluginManagement>
6681
<plugins>
6782
<plugin>
6883
<?m2e ignore?>

grpc-google-cloud-spanner-v1/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<groupId>com.google.guava</groupId>
3838
<artifactId>guava</artifactId>
3939
</dependency>
40+
<dependency>
41+
<groupId>com.google.auto.value</groupId>
42+
<artifactId>auto-value-annotations</artifactId>
43+
</dependency>
4044
</dependencies>
4145

4246
<profiles>
@@ -55,6 +59,17 @@
5559
</profiles>
5660

5761
<build>
62+
<pluginManagement>
63+
<plugins>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-dependency-plugin</artifactId>
67+
<configuration>
68+
<ignoredDependencies>com.google.auto.value:auto-value-annotations</ignoredDependencies>
69+
</configuration>
70+
</plugin>
71+
</plugins>
72+
</pluginManagement>
5873
<plugins>
5974
<plugin>
6075
<?m2e ignore?>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>com.google.cloud</groupId>
1616
<artifactId>google-cloud-shared-config</artifactId>
17-
<version>0.6.0</version>
17+
<version>0.7.0</version>
1818
</parent>
1919

2020
<developers>

samples/install-without-bom/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>com.google.cloud.samples</groupId>
1616
<artifactId>shared-configuration</artifactId>
17-
<version>1.0.17</version>
17+
<version>1.0.18</version>
1818
</parent>
1919

2020
<properties>
@@ -29,7 +29,7 @@
2929
<dependency>
3030
<groupId>com.google.cloud</groupId>
3131
<artifactId>google-cloud-spanner</artifactId>
32-
<version>1.55.0</version>
32+
<version>1.55.1</version>
3333
</dependency>
3434
<!-- [END spanner_install_without_bom] -->
3535

samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<groupId>com.google.cloud.samples</groupId>
2020
<artifactId>shared-configuration</artifactId>
21-
<version>1.0.17</version>
21+
<version>1.0.18</version>
2222
</parent>
2323

2424
<properties>

samples/snapshot/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>com.google.cloud.samples</groupId>
1616
<artifactId>shared-configuration</artifactId>
17-
<version>1.0.17</version>
17+
<version>1.0.18</version>
1818
</parent>
1919

2020
<properties>

0 commit comments

Comments
 (0)