diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 9786771c43..3473042c08 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:3c950ed12391ebaffd1ee66d0374766a1c50144ebe6a7a0042300b2e6bb5856b + digest: sha256:df8d7b2cc0dbc65871e7edd86601901a0612b272fa3f7f0eb590c5c53aa5f92e diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0eddd3d4fc..51efda31d4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,3 +5,6 @@ Thank you for opening a Pull Request! Before submitting your PR, there are a few - [ ] Appropriate docs were updated (if necessary) Fixes # ☕️ + +If you write sample code, please follow the [samples format]( +https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md). diff --git a/.github/workflows/approve-readme.yaml b/.github/workflows/approve-readme.yaml index 1bb1823276..f5fc7d5169 100644 --- a/.github/workflows/approve-readme.yaml +++ b/.github/workflows/approve-readme.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' steps: - - uses: actions/github-script@v5 + - uses: actions/github-script@v6 with: github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} script: | diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml index 18e23230d9..7a106d007e 100644 --- a/.github/workflows/auto-release.yaml +++ b/.github/workflows/auto-release.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest if: contains(github.head_ref, 'release-please') steps: - - uses: actions/github-script@v5 + - uses: actions/github-script@v6 with: github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} debug: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6b5e56aaac..83ef7f9c2c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,8 +27,8 @@ jobs: matrix: java: [8, 11, 17] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: zulu java-version: ${{matrix.java}} @@ -39,8 +39,8 @@ jobs: windows: runs-on: windows-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: zulu java-version: 8 @@ -54,8 +54,8 @@ jobs: matrix: java: [8, 11, 17] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: zulu java-version: ${{matrix.java}} @@ -64,8 +64,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: zulu java-version: 11 @@ -76,8 +76,8 @@ jobs: clirr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: zulu java-version: 8 diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml index d5d964df15..912ed8b2b0 100644 --- a/.github/workflows/samples.yaml +++ b/.github/workflows/samples.yaml @@ -20,9 +20,10 @@ jobs: checkstyle: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: + distribution: zulu java-version: 8 - name: Run checkstyle run: mvn -P lint --quiet --batch-mode checkstyle:check diff --git a/.kokoro/build.bat b/.kokoro/build.bat index cc602c9eba..067cf4a4c4 100644 --- a/.kokoro/build.bat +++ b/.kokoro/build.bat @@ -1,18 +1,18 @@ +:: Copyright 2022 Google LLC +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: Github action job to test core java library features on +:: downstream client libraries before they are released. :: See documentation in type-shell-output.bat -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Github action job to test core java library features on -# downstream client libraries before they are released. "C:\Program Files\Git\bin\bash.exe" %~dp0build.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e9adc2177..8af93a8aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +### [2.9.1](https://github.com/googleapis/java-bigquery/compare/v2.9.0...v2.9.1) (2022-03-03) + + +### Bug Fixes + +* adjusting retry logic to avoid retrying successful job creation ([#1879](https://github.com/googleapis/java-bigquery/issues/1879)) ([fd07533](https://github.com/googleapis/java-bigquery/commit/fd0753338e15965347683345b0e51838baf5d9f6)) +* **java:** add additional configurations to fix native image tests ([#1859](https://github.com/googleapis/java-bigquery/issues/1859)) ([3e82960](https://github.com/googleapis/java-bigquery/commit/3e82960f75ced489f9f0e72fe45165ab866f1d8b)) + + +### Documentation + +* **sample:** Table exists sample fix ([#1868](https://github.com/googleapis/java-bigquery/issues/1868)) ([698306e](https://github.com/googleapis/java-bigquery/commit/698306e480b5f3a180c62b6d9ae0d919e05154d3)) + + +### Dependencies + +* update dependency com.google.apis:google-api-services-bigquery to v2-rev20220220-1.32.1 ([#1872](https://github.com/googleapis/java-bigquery/issues/1872)) ([e67cf65](https://github.com/googleapis/java-bigquery/commit/e67cf65bc044d07ba386f98cf67d2e16144255d0)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.8.0 ([#1876](https://github.com/googleapis/java-bigquery/issues/1876)) ([a16985f](https://github.com/googleapis/java-bigquery/commit/a16985f79f5e09ee6567caf3eb502d7e88103f97)) +* update dependency com.google.cloud:google-cloud-storage to v2.4.2 ([#1853](https://github.com/googleapis/java-bigquery/issues/1853)) ([ef91109](https://github.com/googleapis/java-bigquery/commit/ef91109821a702a6b55b4f1265e812578ca881d8)) +* update dependency com.google.cloud:google-cloud-storage to v2.4.4 ([#1873](https://github.com/googleapis/java-bigquery/issues/1873)) ([a4deb16](https://github.com/googleapis/java-bigquery/commit/a4deb16ed54edf51608f27b47b0846fb23c553fd)) +* update dependency com.google.cloud:native-image-support to v0.12.4 ([#1855](https://github.com/googleapis/java-bigquery/issues/1855)) ([376738d](https://github.com/googleapis/java-bigquery/commit/376738d5fb7253de6e2e9d574aa99e9d7a9e67ad)) +* update dependency com.google.cloud:native-image-support to v0.12.5 ([#1874](https://github.com/googleapis/java-bigquery/issues/1874)) ([c68c49a](https://github.com/googleapis/java-bigquery/commit/c68c49a26abdcce8468b5e848cf39c458aba4774)) +* update dependency com.google.cloud:native-image-support to v0.12.6 ([#1878](https://github.com/googleapis/java-bigquery/issues/1878)) ([3749921](https://github.com/googleapis/java-bigquery/commit/3749921d6d120ffd79941c9ede64822cea03f1cd)) +* update dependency com.google.code.gson:gson to v2.9.0 ([#1850](https://github.com/googleapis/java-bigquery/issues/1850)) ([627da62](https://github.com/googleapis/java-bigquery/commit/627da62bd02314c673c345bd8eb87e973a805bc7)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.10 ([#1860](https://github.com/googleapis/java-bigquery/issues/1860)) ([b31b44c](https://github.com/googleapis/java-bigquery/commit/b31b44c170b1bc948daaae1a9ae6c469370f986c)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.10 ([#1861](https://github.com/googleapis/java-bigquery/issues/1861)) ([ae05dfe](https://github.com/googleapis/java-bigquery/commit/ae05dfed0e670826f7674dc092b91bd5f634bf97)) + ## [2.9.0](https://github.com/googleapis/java-bigquery/compare/v2.8.0...v2.9.0) (2022-02-11) diff --git a/README.md b/README.md index 82c393b42f..b5057ae0eb 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google com.google.cloud libraries-bom - 24.3.0 + 24.4.0 pom import @@ -44,7 +44,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-bigquery - 2.8.0 + 2.9.0 ``` @@ -52,20 +52,20 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:24.3.0') +implementation platform('com.google.cloud:libraries-bom:24.4.0') implementation 'com.google.cloud:google-cloud-bigquery' ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-bigquery:2.8.0' +implementation 'com.google.cloud:google-cloud-bigquery:2.9.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.8.0" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.9.0" ``` ## Authentication diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 8472c7ebb2..336b7f398f 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -6,7 +6,7 @@ google-cloud-bigquery-parent com.google.cloud - 2.9.0 + 2.9.1 @@ -37,7 +37,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.9.0 + 3.10.0 org.apache.maven.plugins @@ -83,7 +83,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.12 true diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml index 123f95281e..402ae4e297 100644 --- a/google-cloud-bigquery/pom.xml +++ b/google-cloud-bigquery/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-bigquery - 2.9.0 + 2.9.1 jar BigQuery https://github.com/googleapis/java-bigquery @@ -11,7 +11,7 @@ com.google.cloud google-cloud-bigquery-parent - 2.9.0 + 2.9.1 google-cloud-bigquery diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryRetryAlgorithm.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryRetryAlgorithm.java index af472430fc..0429b7f005 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryRetryAlgorithm.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryRetryAlgorithm.java @@ -25,6 +25,8 @@ import com.google.api.gax.retrying.TimedAttemptSettings; import com.google.api.gax.retrying.TimedRetryAlgorithm; import com.google.api.gax.retrying.TimedRetryAlgorithmWithContext; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import java.util.Iterator; import java.util.UUID; import java.util.concurrent.CancellationException; @@ -107,9 +109,10 @@ private boolean shouldRetryBasedOnBigQueryRetryConfig( /* In some cases error messages may come without an exception e.g. status code 200 with a rate limit exceeded for job create - in these cases there is now previousThrowable so we need to check previousResponse + in these cases there is no previousThrowable so we need + to check for error messages in previousResponse */ - errorDesc = previousResponse.toString(); + errorDesc = getErrorDescFromResponse(previousResponse); } if (errorDesc != null) { @@ -212,4 +215,28 @@ private TimedAttemptSettings createNextAttemptBasedOnTiming( } return getTimedAlgorithm().createNextAttempt(previousSettings); } + + private String getErrorDescFromResponse(ResponseT previousResponse) { + /* + error messages may come without an exception and must be extracted from response + following logic based on response body of jobs.insert method, so far the only + known case where a response with status code 200 may contain an error message + */ + try { + JsonObject responseJson = + JsonParser.parseString(previousResponse.toString()).getAsJsonObject(); + if (responseJson.has("status") && responseJson.getAsJsonObject("status").has("errorResult")) { + return responseJson + .getAsJsonObject("status") + .getAsJsonObject("errorResult") + .get("message") + .toString(); + } else { + return null; + } + } catch (Exception e) { + // exceptions here implies no error message present in response, returning null + return null; + } + } } diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index 282bef986c..9cab253a21 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -125,10 +125,10 @@ import com.google.common.io.BaseEncoding; import com.google.gson.JsonObject; import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.nio.file.FileSystems; import java.time.Instant; import java.time.Period; import java.util.ArrayList; @@ -472,9 +472,10 @@ public static void beforeClass() throws InterruptedException, IOException { .setContentType("application/json") .build(), JSON_CONTENT_SIMPLE.getBytes(StandardCharsets.UTF_8)); + InputStream stream = + ITBigQueryTest.class.getClassLoader().getResourceAsStream("QueryTestData.csv"); storage.createFrom( - BlobInfo.newBuilder(BUCKET, LOAD_FILE_LARGE).setContentType("text/plain").build(), - FileSystems.getDefault().getPath("src/test/resources", "QueryTestData.csv")); + BlobInfo.newBuilder(BUCKET, LOAD_FILE_LARGE).setContentType("text/plain").build(), stream); DatasetInfo info = DatasetInfo.newBuilder(DATASET).setDescription(DESCRIPTION).setLabels(LABELS).build(); bigquery.create(info); diff --git a/google-cloud-bigquery/src/test/resources/META-INF/native-image/reflect-config.json b/google-cloud-bigquery/src/test/resources/META-INF/native-image/reflect-config.json new file mode 100644 index 0000000000..b999445994 --- /dev/null +++ b/google-cloud-bigquery/src/test/resources/META-INF/native-image/reflect-config.json @@ -0,0 +1,23 @@ +[ + { + "name":"java.lang.Object", + "methods":[{"name":"","parameterTypes":[] }] + }, + { + "name":"com.google.api.client.googleapis.json.GoogleJsonError", + "methods":[ + {"name":"","parameterTypes":[] }] + }, + { + "name":"com.google.api.client.googleapis.json.GoogleJsonError$Details", + "methods":[{"name":"","parameterTypes":[] }] + }, + { + "name":"com.google.api.client.googleapis.json.GoogleJsonError$ErrorInfo", + "methods":[{"name":"","parameterTypes":[]}] + }, + { + "name":"java.util.HashMap", + "methods":[{"name":"","parameterTypes":[] }] + } +] \ No newline at end of file diff --git a/google-cloud-bigquery/src/test/resources/META-INF/native-image/resource-config.json b/google-cloud-bigquery/src/test/resources/META-INF/native-image/resource-config.json new file mode 100644 index 0000000000..e00ed1f1c5 --- /dev/null +++ b/google-cloud-bigquery/src/test/resources/META-INF/native-image/resource-config.json @@ -0,0 +1,3 @@ +{ + "resources":[{"pattern": ".*.csv"}] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4048b0b992..bf73724afe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-bigquery-parent pom - 2.9.0 + 2.9.1 BigQuery Parent https://github.com/googleapis/java-bigquery @@ -53,8 +53,8 @@ UTF-8 github google-cloud-bigquery-parent - v2-rev20220123-1.32.1 - 2.7.0 + v2-rev20220220-1.32.1 + 2.8.0 @@ -84,7 +84,7 @@ com.google.cloud google-cloud-bigquery - 2.9.0 + 2.9.1 @@ -97,7 +97,7 @@ com.google.code.gson gson - 2.8.9 + 2.9.0 @@ -135,7 +135,7 @@ com.google.cloud google-cloud-storage - 2.4.1 + 2.4.4 test @@ -157,7 +157,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.2.1 + 3.2.2 diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 4b3ba9df96..115af2736a 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -45,7 +45,7 @@ com.google.cloud google-cloud-bigquery - 2.8.0 + 2.9.0 @@ -69,7 +69,7 @@ com.google.cloud google-cloud-bigqueryconnection - 2.1.9 + 2.1.10 test diff --git a/samples/native-image-sample/pom.xml b/samples/native-image-sample/pom.xml index 6e3fced6bd..75cad8958d 100644 --- a/samples/native-image-sample/pom.xml +++ b/samples/native-image-sample/pom.xml @@ -39,7 +39,7 @@ com.google.cloud libraries-bom - 24.3.0 + 24.4.0 pom import @@ -93,7 +93,7 @@ com.google.cloud native-image-support - 0.12.3 + 0.12.6 org.junit.vintage @@ -104,7 +104,7 @@ org.graalvm.buildtools junit-platform-native - 0.9.9 + 0.9.10 test @@ -126,7 +126,7 @@ org.graalvm.buildtools native-maven-plugin - 0.9.9 + 0.9.10 true com.example.bigquery.NativeImageBigquerySample diff --git a/samples/pom.xml b/samples/pom.xml index a02b0b6c46..4e280e644d 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -63,7 +63,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.12 true diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 312c274576..c2e0ebb5d0 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigquery - 2.9.0 + 2.9.1 @@ -67,7 +67,7 @@ com.google.cloud google-cloud-bigqueryconnection - 2.1.9 + 2.1.10 test diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 8a7caea9d9..4c0b2d95f2 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -47,7 +47,7 @@ com.google.cloud libraries-bom - 24.3.0 + 24.4.0 pom import @@ -85,7 +85,7 @@ com.google.cloud google-cloud-bigqueryconnection - 2.1.9 + 2.1.10 test @@ -117,7 +117,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.12 true diff --git a/samples/snippets/src/main/java/com/example/bigquery/TableExists.java b/samples/snippets/src/main/java/com/example/bigquery/TableExists.java index 0775c2548b..0447fe3de1 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/TableExists.java +++ b/samples/snippets/src/main/java/com/example/bigquery/TableExists.java @@ -40,7 +40,10 @@ public static void tableExists(String datasetName, String tableName) { BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); Table table = bigquery.getTable(TableId.of(datasetName, tableName)); - if (table.exists()) { + if (table != null + && table + .exists()) { // table will be null if it is not found and setThrowNotFound is not set + // to `true` System.out.println("Table already exist"); } else { System.out.println("Table not found"); diff --git a/samples/snippets/src/test/java/com/example/bigquery/TableExistsIT.java b/samples/snippets/src/test/java/com/example/bigquery/TableExistsIT.java index 4ff04e4efa..4573648a61 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/TableExistsIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/TableExistsIT.java @@ -61,7 +61,6 @@ public void setUp() { System.setOut(out); // create a temporary table tableName = "MY_TABLE_NAME_TEST_" + UUID.randomUUID().toString().substring(0, 8); - CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, Schema.of()); } @After @@ -76,6 +75,9 @@ public void tearDown() { @Test public void testTableExists() { + TableExists.tableExists(BIGQUERY_DATASET_NAME, tableName); + assertThat(bout.toString()).contains("Table not found"); + CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, Schema.of()); TableExists.tableExists(BIGQUERY_DATASET_NAME, tableName); assertThat(bout.toString()).contains("Table already exist"); } diff --git a/versions.txt b/versions.txt index 8dc052a16a..bb05ed50ce 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-bigquery:2.9.0:2.9.0 \ No newline at end of file +google-cloud-bigquery:2.9.1:2.9.1 \ No newline at end of file