Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: backend now supports optimizer version for DML #252

Merged
merged 8 commits into from Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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