Skip to content
Permalink
Browse files
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
  • Loading branch information
olavloite committed Jun 10, 2020
1 parent 13e47c3 commit 24b986b03a785f4c5ee978dcdc57f51687701e52
@@ -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)
@@ -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>
@@ -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()
@@ -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
@@ -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>
@@ -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?>
@@ -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>
@@ -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?>
@@ -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>
@@ -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?>
@@ -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>
@@ -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>
@@ -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] -->

@@ -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>
@@ -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>
@@ -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>

0 comments on commit 24b986b

Please sign in to comment.