From 7f28f440196b4c1d99f1458bb0118b235fa1cf70 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 4 Jun 2021 15:48:08 +0000 Subject: [PATCH 1/7] chore: release 2.2.2-SNAPSHOT (#492) :robot: I have created a release \*beep\* \*boop\* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- versions.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 63386911a..2ab9e3259 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 google-cloud-spanner-jdbc - 2.2.1 + 2.2.2-SNAPSHOT jar Google Cloud Spanner JDBC https://github.com/googleapis/java-spanner-jdbc diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 9a1c8deb9..af73bc325 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-spanner-jdbc - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/versions.txt b/versions.txt index 89b98cc51..9debde31d 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-spanner-jdbc:2.2.1:2.2.1 +google-cloud-spanner-jdbc:2.2.1:2.2.2-SNAPSHOT From ee3028b7ca9151c8368dc0a8cc546f144c3adc06 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 5 Jun 2021 11:50:18 +0200 Subject: [PATCH 2/7] chore(deps): update dependency com.google.cloud:google-cloud-spanner-jdbc to v2.2.1 (#493) --- samples/install-without-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index e1d154cef..79f600b32 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-spanner-jdbc - 2.2.0 + 2.2.1 From 554ff0508453712bb8f54394be9bf774d7cdf9b4 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 5 Jun 2021 11:50:38 +0200 Subject: [PATCH 3/7] chore(deps): update dependency com.google.cloud.samples:shared-configuration to v1.0.23 (#494) --- samples/install-without-bom/pom.xml | 2 +- samples/pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- samples/snippets/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 79f600b32..534229914 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.22 + 1.0.23 diff --git a/samples/pom.xml b/samples/pom.xml index 08d34f32f..b50770aae 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -18,7 +18,7 @@ com.google.cloud.samples shared-configuration - 1.0.22 + 1.0.23 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index af73bc325..3e2a541e0 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.22 + 1.0.23 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index d29022a68..87e63b006 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.22 + 1.0.23 From 184c232c2f7766dcc996bb3c8c928b80b401b6c0 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Sat, 5 Jun 2021 03:08:06 -0700 Subject: [PATCH 4/7] chore: regenerate README (#495) This PR was generated using Autosynth. :rainbow:
Log from Synthtool ``` 2021-06-05 09:53:24,030 synthtool [DEBUG] > Executing /root/.cache/synthtool/java-spanner-jdbc/.github/readme/synth.py. On branch autosynth-readme nothing to commit, working tree clean 2021-06-05 09:53:25,229 synthtool [DEBUG] > Wrote metadata to .github/readme/synth.metadata/synth.metadata. ```
Full log will be available here: https://source.cloud.google.com/results/invocations/2c57a5bd-142d-430b-9931-a1a1a7e59a30/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) --- .github/readme/synth.metadata/synth.metadata | 4 ++-- README.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index 55f35bca4..720b019d5 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-spanner-jdbc.git", - "sha": "4d7ad154135b066eb0cf4f9563933c978f4e6943" + "sha": "554ff0508453712bb8f54394be9bf774d7cdf9b4" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "c3e41da0fa256ad7f6b4bc76b9d069dedecdfef4" + "sha": "8da7927493739fa36130360019ca21258242f73a" } } ] diff --git a/README.md b/README.md index 79fbfd8ef..92c748d85 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,18 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-spanner-jdbc - 2.2.0 + 2.2.1 ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-spanner-jdbc:2.2.0' +compile 'com.google.cloud:google-cloud-spanner-jdbc:2.2.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-spanner-jdbc" % "2.2.0" +libraryDependencies += "com.google.cloud" % "google-cloud-spanner-jdbc" % "2.2.1" ``` ## Authentication From e27e947afacedbd4c460ee91a9e2156c793e2ea3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 7 Jun 2021 21:00:18 +0200 Subject: [PATCH 5/7] chore(deps): update dependency com.google.cloud:libraries-bom to v20.6.0 (#496) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java) | `20.5.0` -> `20.6.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/20.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/20.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/20.6.0/compatibility-slim/20.5.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/20.6.0/confidence-slim/20.5.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-spanner-jdbc). --- samples/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 87e63b006..321b143cb 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 20.5.0 + 20.6.0 pom import From 5849a970087d3fa1d1b42092b4568602563a1dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Thu, 10 Jun 2021 02:54:52 +0200 Subject: [PATCH 6/7] deps: update dependency com.google.cloud:google-cloud-spanner-bom to v6.6.0 (#498) * deps: update dependency com.google.cloud:google-cloud-spanner-bom to v6.6.0 Updates to Spanner client 6.6.0 and adds tests for optimizer stats package. Replaces #497 * test: implement missing method for integration test --- pom.xml | 2 +- .../spanner/jdbc/JdbcQueryOptionsTest.java | 110 ++++++++++++++---- .../jdbc/it/ITJdbcQueryOptionsTest.java | 40 +++++-- 3 files changed, 117 insertions(+), 35 deletions(-) diff --git a/pom.xml b/pom.xml index 2ab9e3259..056534bbb 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ com.google.cloud google-cloud-spanner-bom - 6.5.0 + 6.6.0 pom import diff --git a/src/test/java/com/google/cloud/spanner/jdbc/JdbcQueryOptionsTest.java b/src/test/java/com/google/cloud/spanner/jdbc/JdbcQueryOptionsTest.java index d26aba592..d1aeeb92d 100644 --- a/src/test/java/com/google/cloud/spanner/jdbc/JdbcQueryOptionsTest.java +++ b/src/test/java/com/google/cloud/spanner/jdbc/JdbcQueryOptionsTest.java @@ -20,6 +20,7 @@ import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.SpannerOptions.SpannerEnvironment; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.connection.AbstractMockServerTest; import com.google.common.base.MoreObjects; @@ -40,7 +41,7 @@ public void setup() throws Exception { } @Test - public void testDefaultOptimizerVersion() throws SQLException { + public void testDefaultOptions() throws SQLException { try (java.sql.Connection connection = createJdbcConnection()) { try (java.sql.ResultSet rs = connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_VERSION")) { @@ -48,25 +49,39 @@ public void testDefaultOptimizerVersion() throws SQLException { assertThat(rs.getString("OPTIMIZER_VERSION")).isEqualTo(""); assertThat(rs.next()).isFalse(); } + try (java.sql.ResultSet rs = + connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_STATISTICS_PACKAGE")) { + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("OPTIMIZER_STATISTICS_PACKAGE")).isEqualTo(""); + assertThat(rs.next()).isFalse(); + } } } @Test - public void testOptimizerVersionInConnectionUrl() throws SQLException { + public void testOptionsInConnectionUrl() throws SQLException { try (java.sql.Connection connection = DriverManager.getConnection( - String.format("jdbc:%s;optimizerVersion=%s", getBaseUrl(), "100"))) { + String.format( + "jdbc:%s;optimizerVersion=%s;optimizerStatisticsPackage=%s", + getBaseUrl(), "100", "url_package"))) { try (java.sql.ResultSet rs = connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_VERSION")) { assertThat(rs.next()).isTrue(); assertThat(rs.getString("OPTIMIZER_VERSION")).isEqualTo("100"); assertThat(rs.next()).isFalse(); } + try (java.sql.ResultSet rs = + connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_STATISTICS_PACKAGE")) { + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("OPTIMIZER_STATISTICS_PACKAGE")).isEqualTo("url_package"); + assertThat(rs.next()).isFalse(); + } } } @Test - public void testSetOptimizerVersion() throws SQLException { + public void testSetOptions() throws SQLException { try (java.sql.Connection connection = createJdbcConnection()) { connection.createStatement().execute("SET OPTIMIZER_VERSION='20'"); try (java.sql.ResultSet rs = @@ -89,41 +104,64 @@ public void testSetOptimizerVersion() throws SQLException { assertThat(rs.getString("OPTIMIZER_VERSION")).isEqualTo(""); assertThat(rs.next()).isFalse(); } + + connection.createStatement().execute("SET OPTIMIZER_STATISTICS_PACKAGE='20210609'"); + try (java.sql.ResultSet rs = + connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_STATISTICS_PACKAGE")) { + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("OPTIMIZER_STATISTICS_PACKAGE")).isEqualTo("20210609"); + assertThat(rs.next()).isFalse(); + } + connection.createStatement().execute("SET OPTIMIZER_STATISTICS_PACKAGE='latest'"); + try (java.sql.ResultSet rs = + connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_STATISTICS_PACKAGE")) { + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("OPTIMIZER_STATISTICS_PACKAGE")).isEqualTo("latest"); + assertThat(rs.next()).isFalse(); + } + connection.createStatement().execute("SET OPTIMIZER_STATISTICS_PACKAGE=''"); + try (java.sql.ResultSet rs = + connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_STATISTICS_PACKAGE")) { + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("OPTIMIZER_STATISTICS_PACKAGE")).isEqualTo(""); + assertThat(rs.next()).isFalse(); + } } } @Test - public void testSetAndUseOptimizerVersion() throws SQLException { + public void testSetAndUseOptions() throws SQLException { try (java.sql.Connection connection = createJdbcConnection()) { connection.createStatement().execute("SET OPTIMIZER_VERSION='20'"); + connection.createStatement().execute("SET OPTIMIZER_STATISTICS_PACKAGE='20210609'"); try (java.sql.ResultSet rs = connection.createStatement().executeQuery(SELECT_COUNT_STATEMENT.getSql())) { assertThat(rs.next()).isTrue(); assertThat(rs.getLong(1)).isEqualTo(COUNT_BEFORE_INSERT); assertThat(rs.next()).isFalse(); - // Verify that the last ExecuteSqlRequest that the server received specified optimizer - // version 20. + // Verify that the last ExecuteSqlRequest that the server received used the options that + // were set. ExecuteSqlRequest request = getLastExecuteSqlRequest(); assertThat(request.getQueryOptions().getOptimizerVersion()).isEqualTo("20"); + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()).isEqualTo("20210609"); } - // Do another query, but now with optimizer version 'latest'. connection.createStatement().execute("SET OPTIMIZER_VERSION='latest'"); + connection.createStatement().execute("SET OPTIMIZER_STATISTICS_PACKAGE='latest'"); try (java.sql.ResultSet rs = connection.createStatement().executeQuery(SELECT_COUNT_STATEMENT.getSql())) { assertThat(rs.next()).isTrue(); assertThat(rs.getLong(1)).isEqualTo(COUNT_BEFORE_INSERT); assertThat(rs.next()).isFalse(); - // Verify that the last ExecuteSqlRequest that the server received specified optimizer - // version 'latest'. ExecuteSqlRequest request = getLastExecuteSqlRequest(); assertThat(request.getQueryOptions().getOptimizerVersion()).isEqualTo("latest"); + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()).isEqualTo("latest"); } - // Set the optimizer version to ''. This will do a fallback to the default, meaning that it - // will be read from the environment variable SPANNER_OPTIMIZER_VERSION as we have nothing set - // on the connection URL. + // Set the options to ''. This will do a fallback to the default, meaning that it will be read + // from the environment variables as we have nothing set on the connection URL. connection.createStatement().execute("SET OPTIMIZER_VERSION=''"); + connection.createStatement().execute("SET OPTIMIZER_STATISTICS_PACKAGE=''"); try (java.sql.ResultSet rs = connection.createStatement().executeQuery(SELECT_COUNT_STATEMENT.getSql())) { assertThat(rs.next()).isTrue(); @@ -134,31 +172,49 @@ public void testSetAndUseOptimizerVersion() throws SQLException { ExecuteSqlRequest request = getLastExecuteSqlRequest(); assertThat(request.getQueryOptions().getOptimizerVersion()) .isEqualTo(MoreObjects.firstNonNull(System.getenv("SPANNER_OPTIMIZER_VERSION"), "")); + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()) + .isEqualTo(MoreObjects.firstNonNull(System.getenv("OPTIMIZER_STATISTICS_PACKAGE"), "")); } } } @Test - public void testUseOptimizerVersionFromConnectionUrl() throws SQLException { + public void testUseOptionsFromConnectionUrl() throws SQLException { try (java.sql.Connection connection = - DriverManager.getConnection(String.format("jdbc:%s;optimizerVersion=10", getBaseUrl()))) { + DriverManager.getConnection( + String.format( + "jdbc:%s;optimizerVersion=10;optimizerStatisticsPackage=20210609_10_00_00", + getBaseUrl()))) { // Do a query and verify that the version from the connection URL is used. try (java.sql.ResultSet rs = connection.createStatement().executeQuery(SELECT_COUNT_STATEMENT.getSql())) { assertThat(rs.next()).isTrue(); assertThat(rs.getLong(1)).isEqualTo(COUNT_BEFORE_INSERT); assertThat(rs.next()).isFalse(); - // The optimizer version used should be '10' from the connection URL. + // The options should come from the connection URL. ExecuteSqlRequest request = getLastExecuteSqlRequest(); assertThat(request.getQueryOptions().getOptimizerVersion()).isEqualTo("10"); + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()) + .isEqualTo("20210609_10_00_00"); } } } @Test - public void testUseOptimizerVersionFromEnvironment() throws SQLException { + public void testUseOptionsFromEnvironment() throws SQLException { try { - SpannerOptions.useEnvironment(() -> "20"); + SpannerOptions.useEnvironment( + new SpannerEnvironment() { + @Override + public String getOptimizerVersion() { + return "20"; + } + + @Override + public String getOptimizerStatisticsPackage() { + return "env_package"; + } + }); try (java.sql.Connection connection = DriverManager.getConnection(String.format("jdbc:%s", getBaseUrl()))) { // Do a query and verify that the version from the environment is used. @@ -170,6 +226,8 @@ public void testUseOptimizerVersionFromEnvironment() throws SQLException { // Verify query options from the environment. ExecuteSqlRequest request = getLastExecuteSqlRequest(); assertThat(request.getQueryOptions().getOptimizerVersion()).isEqualTo("20"); + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()) + .isEqualTo("env_package"); } // Now set one of the query options on the connection. That option should be used in // combination with the other option from the environment. @@ -183,6 +241,9 @@ public void testUseOptimizerVersionFromEnvironment() throws SQLException { ExecuteSqlRequest request = getLastExecuteSqlRequest(); // Optimizer version should come from the connection. assertThat(request.getQueryOptions().getOptimizerVersion()).isEqualTo("30"); + // Optimizer statistics package should come from the environment. + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()) + .isEqualTo("env_package"); } } } finally { @@ -195,7 +256,9 @@ public void testUseQueryHint() throws SQLException { mockSpanner.putStatementResult( StatementResult.query( Statement.of( - String.format("@{optimizer_version=1} %s", SELECT_COUNT_STATEMENT.getSql())), + String.format( + "@{optimizer_version=1, optimizer_statistics_package=hint_package} %s", + SELECT_COUNT_STATEMENT.getSql())), SELECT_COUNT_RESULTSET_BEFORE_INSERT)); try (java.sql.Connection connection = DriverManager.getConnection(String.format("jdbc:%s", getBaseUrl()))) { @@ -203,14 +266,17 @@ public void testUseQueryHint() throws SQLException { connection .createStatement() .executeQuery( - String.format("@{optimizer_version=1} %s", SELECT_COUNT_STATEMENT.getSql()))) { + String.format( + "@{optimizer_version=1, optimizer_statistics_package=hint_package} %s", + SELECT_COUNT_STATEMENT.getSql()))) { assertThat(rs.next()).isTrue(); assertThat(rs.getLong(1)).isEqualTo(COUNT_BEFORE_INSERT); assertThat(rs.next()).isFalse(); - // The optimizer version used in the ExecuteSqlRequest should be empty as the query hint is - // parsed by the backend. + // The options used in the ExecuteSqlRequest should be empty as the query hint is parsed by + // the backend. ExecuteSqlRequest request = getLastExecuteSqlRequest(); assertThat(request.getQueryOptions().getOptimizerVersion()).isEqualTo(""); + assertThat(request.getQueryOptions().getOptimizerStatisticsPackage()).isEqualTo(""); } } } diff --git a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcQueryOptionsTest.java b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcQueryOptionsTest.java index 7ca650dfc..ac90687c8 100644 --- a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcQueryOptionsTest.java +++ b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcQueryOptionsTest.java @@ -17,6 +17,9 @@ package com.google.cloud.spanner.jdbc.it; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeFalse; @@ -25,6 +28,7 @@ import com.google.cloud.spanner.connection.SpannerPool; import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; import com.google.cloud.spanner.jdbc.JdbcSqlException; +import com.google.cloud.spanner.testing.EmulatorSpannerHelper; import com.google.rpc.Code; import com.google.spanner.v1.ExecuteSqlRequest.QueryOptions; import java.sql.Connection; @@ -96,7 +100,8 @@ public void connectionUrl() throws SQLException { @Test public void connectionUrlWithInvalidOptimizerVersion() throws SQLException { - assumeFalse("optimizer version is ignored on emulator", env.getTestHelper().isEmulator()); + assumeFalse( + "optimizer version is ignored on emulator", EmulatorSpannerHelper.isUsingEmulator()); this.connectionUriSuffix = ";optimizerVersion=9999999"; try (Connection connection = createConnection()) { try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) { @@ -139,7 +144,8 @@ public void setLatestOptimizerVersion() throws SQLException { @Test public void setInvalidOptimizerVersion() throws SQLException { - assumeFalse("optimizer version is ignored on emulator", env.getTestHelper().isEmulator()); + assumeFalse( + "optimizer version is ignored on emulator", EmulatorSpannerHelper.isUsingEmulator()); try (Connection connection = createConnection()) { connection.createStatement().execute("SET OPTIMIZER_VERSION='9999999'"); try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) { @@ -156,7 +162,7 @@ public void setInvalidOptimizerVersion() throws SQLException { public void optimizerVersionInQueryHint() throws SQLException { assumeFalse( "optimizer version in query hint is not supported on emulator", - env.getTestHelper().isEmulator()); + EmulatorSpannerHelper.isUsingEmulator()); try (Connection connection = createConnection()) { verifyOptimizerVersion(connection, ""); try (ResultSet rs = @@ -175,8 +181,9 @@ public void optimizerVersionInQueryHint() throws SQLException { } @Test - public void optimizerVersionInEnvironment() throws SQLException { - assumeFalse("optimizer version is ignored on emulator", env.getTestHelper().isEmulator()); + public void testOptionsInEnvironment() throws SQLException { + assumeFalse( + "optimizer version is ignored on emulator", EmulatorSpannerHelper.isUsingEmulator()); try { SpannerOptions.useEnvironment( new SpannerOptions.SpannerEnvironment() { @@ -184,6 +191,11 @@ public void optimizerVersionInEnvironment() throws SQLException { public String getOptimizerVersion() { return "1"; } + + @Override + public String getOptimizerStatisticsPackage() { + return "latest"; + } }); try (Connection connection = createConnection()) { // Environment query options are not visible to the connection. @@ -204,15 +216,19 @@ public String getOptimizerVersion() { public String getOptimizerVersion() { return "9999999"; } + + @Override + public String getOptimizerStatisticsPackage() { + return "latest"; + } }); try (Connection connection = createConnection()) { - try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) { - fail("missing expected exception"); - } catch (SQLException e) { - assertThat((Throwable) e).isInstanceOf(JdbcSqlException.class); - JdbcSqlException je = (JdbcSqlException) e; - assertThat(je.getCode()).isEqualTo(Code.INVALID_ARGUMENT); - } + SQLException e = + assertThrows( + SQLException.class, () -> connection.createStatement().executeQuery("SELECT 1")); + assertTrue(e instanceof JdbcSqlException); + JdbcSqlException je = (JdbcSqlException) e; + assertEquals(Code.INVALID_ARGUMENT, je.getCode()); } } finally { SpannerOptions.useDefaultEnvironment(); From b42a72a6341c1479a546b31932fc10c3fa1932e5 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 10 Jun 2021 01:14:05 +0000 Subject: [PATCH 7/7] chore: release 2.2.2 (#499) :robot: I have created a release \*beep\* \*boop\* --- ### [2.2.2](https://www.github.com/googleapis/java-spanner-jdbc/compare/v2.2.1...v2.2.2) (2021-06-10) ### Dependencies * update dependency com.google.cloud:google-cloud-spanner-bom to v6.6.0 ([#498](https://www.github.com/googleapis/java-spanner-jdbc/issues/498)) ([5849a97](https://www.github.com/googleapis/java-spanner-jdbc/commit/5849a970087d3fa1d1b42092b4568602563a1dbd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 7 +++++++ pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- versions.txt | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5632e1b..1f2efa91c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [2.2.2](https://www.github.com/googleapis/java-spanner-jdbc/compare/v2.2.1...v2.2.2) (2021-06-10) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-spanner-bom to v6.6.0 ([#498](https://www.github.com/googleapis/java-spanner-jdbc/issues/498)) ([5849a97](https://www.github.com/googleapis/java-spanner-jdbc/commit/5849a970087d3fa1d1b42092b4568602563a1dbd)) + ### [2.2.1](https://www.github.com/googleapis/java-spanner-jdbc/compare/v2.2.0...v2.2.1) (2021-06-04) diff --git a/pom.xml b/pom.xml index 056534bbb..767f5337d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 google-cloud-spanner-jdbc - 2.2.2-SNAPSHOT + 2.2.2 jar Google Cloud Spanner JDBC https://github.com/googleapis/java-spanner-jdbc diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 3e2a541e0..27ed2fe56 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-spanner-jdbc - 2.2.2-SNAPSHOT + 2.2.2 diff --git a/versions.txt b/versions.txt index 9debde31d..2031781d9 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-spanner-jdbc:2.2.1:2.2.2-SNAPSHOT +google-cloud-spanner-jdbc:2.2.2:2.2.2