Skip to content

Commit

Permalink
fix: backend now supports optimizer version for DML (#252)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
olavloite committed Jun 10, 2020
1 parent 13e47c3 commit 24b986b
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 35 deletions.
4 changes: 1 addition & 3 deletions .kokoro/build.sh
Expand Up @@ -51,9 +51,7 @@ test)
RETURN_CODE=$?
;;
lint)
mvn \
-Penable-samples \
com.coveo:fmt-maven-plugin:check
mvn com.coveo:fmt-maven-plugin:check
RETURN_CODE=$?
;;
javadoc)
Expand Down
2 changes: 1 addition & 1 deletion google-cloud-spanner-bom/pom.xml
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-config</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<name>Google Cloud Spanner BOM</name>
Expand Down
Expand Up @@ -107,8 +107,7 @@ public void executeQuery() {

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

// Version '100000' is an invalid value, but is ignored by the backend.
assertThat(
client
.readWriteTransaction()
.run(
new TransactionCallable<Long>() {
@Override
public Long run(TransactionContext transaction) throws Exception {
return transaction.executeUpdate(
Statement.newBuilder("INSERT INTO TEST (ID, NAME) VALUES (@id, @name)")
.bind("id")
.to(3L)
.bind("name")
.to("Three")
.withQueryOptions(
QueryOptions.newBuilder().setOptimizerVersion("10000").build())
.build());
}
}))
.isEqualTo(1L);
// Version '100000' is an invalid value and should cause an error.
try {
client
.readWriteTransaction()
.run(
new TransactionCallable<Long>() {
@Override
public Long run(TransactionContext transaction) throws Exception {
return transaction.executeUpdate(
Statement.newBuilder("INSERT INTO TEST (ID, NAME) VALUES (@id, @name)")
.bind("id")
.to(3L)
.bind("name")
.to("Three")
.withQueryOptions(
QueryOptions.newBuilder().setOptimizerVersion("100000").build())
.build());
}
});
fail("missing expected exception");
} catch (SpannerException e) {
assertThat(e.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT);
assertThat(e.getMessage()).contains("Query optimizer version: 100000 is not supported");
}

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

@Test
Expand Down
15 changes: 15 additions & 0 deletions grpc-google-cloud-spanner-admin-database-v1/pom.xml
Expand Up @@ -37,6 +37,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-iam-v1</artifactId>
Expand All @@ -63,6 +67,17 @@
</profiles>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>com.google.auto.value:auto-value-annotations</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<?m2e ignore?>
Expand Down
15 changes: 15 additions & 0 deletions grpc-google-cloud-spanner-admin-instance-v1/pom.xml
Expand Up @@ -37,6 +37,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-iam-v1</artifactId>
Expand All @@ -63,6 +67,17 @@
</profiles>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>com.google.auto.value:auto-value-annotations</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<?m2e ignore?>
Expand Down
15 changes: 15 additions & 0 deletions grpc-google-cloud-spanner-v1/pom.xml
Expand Up @@ -37,6 +37,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
</dependency>
</dependencies>

<profiles>
Expand All @@ -55,6 +59,17 @@
</profiles>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>com.google.auto.value:auto-value-annotations</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<?m2e ignore?>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-config</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<developers>
Expand Down
4 changes: 2 additions & 2 deletions samples/install-without-bom/pom.xml
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.17</version>
<version>1.0.18</version>
</parent>

<properties>
Expand All @@ -29,7 +29,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
<version>1.55.0</version>
<version>1.55.1</version>
</dependency>
<!-- [END spanner_install_without_bom] -->

Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.17</version>
<version>1.0.18</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion samples/snapshot/pom.xml
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.17</version>
<version>1.0.18</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/pom.xml
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.17</version>
<version>1.0.18</version>
</parent>

<properties>
Expand Down

0 comments on commit 24b986b

Please sign in to comment.