diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bff46cd669..dc05a72762 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:11d59eabd49dc088f8339fb96e9da79ba4b3a73b3d49a8a4e0263e91edd053ba -# created: 2023-12-05T18:46:43.811070085Z \ No newline at end of file + digest: sha256:a6aa751984f1e905c3ae5a3aac78fc7b68210626ce91487dc7ff4f0a06f010cc +# created: 2024-01-22T14:14:20.913785597Z diff --git a/.github/workflows/renovate_config_check.yaml b/.github/workflows/renovate_config_check.yaml new file mode 100644 index 0000000000..87d8eb2be8 --- /dev/null +++ b/.github/workflows/renovate_config_check.yaml @@ -0,0 +1,25 @@ +name: Renovate Bot Config Validation + +on: + pull_request: + paths: + - 'renovate.json' + +jobs: + renovate_bot_config_validation: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install Renovate and Config Validator + run: | + npm install -g npm@latest + npm install --global renovate + renovate-config-validator diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index c7f7f64aaa..6584155eee 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -59,7 +59,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 with: name: SARIF file path: results.sarif @@ -67,6 +67,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@03e7845b7bfcd5e7fb63d1ae8c61b0e791134fab # v2.22.11 + uses: github/codeql-action/upload-sarif@4759df8df70c5ebe7042c3029bbace20eee13edd # v2.23.1 with: sarif_file: results.sarif diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 6a36ccab46..445c5c1f09 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -170,30 +170,30 @@ colorlog==6.7.0 \ --hash=sha256:0d33ca236784a1ba3ff9c532d4964126d8a2c44f1f0cb1d2b0728196f512f662 \ --hash=sha256:bd94bd21c1e13fac7bd3153f4bc3a7dc0eb0974b8bc2fdf1a989e474f6e582e5 # via gcp-docuploader -cryptography==41.0.3 \ - --hash=sha256:0d09fb5356f975974dbcb595ad2d178305e5050656affb7890a1583f5e02a306 \ - --hash=sha256:23c2d778cf829f7d0ae180600b17e9fceea3c2ef8b31a99e3c694cbbf3a24b84 \ - --hash=sha256:3fb248989b6363906827284cd20cca63bb1a757e0a2864d4c1682a985e3dca47 \ - --hash=sha256:41d7aa7cdfded09b3d73a47f429c298e80796c8e825ddfadc84c8a7f12df212d \ - --hash=sha256:42cb413e01a5d36da9929baa9d70ca90d90b969269e5a12d39c1e0d475010116 \ - --hash=sha256:4c2f0d35703d61002a2bbdcf15548ebb701cfdd83cdc12471d2bae80878a4207 \ - --hash=sha256:4fd871184321100fb400d759ad0cddddf284c4b696568204d281c902fc7b0d81 \ - --hash=sha256:5259cb659aa43005eb55a0e4ff2c825ca111a0da1814202c64d28a985d33b087 \ - --hash=sha256:57a51b89f954f216a81c9d057bf1a24e2f36e764a1ca9a501a6964eb4a6800dd \ - --hash=sha256:652627a055cb52a84f8c448185922241dd5217443ca194d5739b44612c5e6507 \ - --hash=sha256:67e120e9a577c64fe1f611e53b30b3e69744e5910ff3b6e97e935aeb96005858 \ - --hash=sha256:6af1c6387c531cd364b72c28daa29232162010d952ceb7e5ca8e2827526aceae \ - --hash=sha256:6d192741113ef5e30d89dcb5b956ef4e1578f304708701b8b73d38e3e1461f34 \ - --hash=sha256:7efe8041897fe7a50863e51b77789b657a133c75c3b094e51b5e4b5cec7bf906 \ - --hash=sha256:84537453d57f55a50a5b6835622ee405816999a7113267739a1b4581f83535bd \ - --hash=sha256:8f09daa483aedea50d249ef98ed500569841d6498aa9c9f4b0531b9964658922 \ - --hash=sha256:95dd7f261bb76948b52a5330ba5202b91a26fbac13ad0e9fc8a3ac04752058c7 \ - --hash=sha256:a74fbcdb2a0d46fe00504f571a2a540532f4c188e6ccf26f1f178480117b33c4 \ - --hash=sha256:a983e441a00a9d57a4d7c91b3116a37ae602907a7618b882c8013b5762e80574 \ - --hash=sha256:ab8de0d091acbf778f74286f4989cf3d1528336af1b59f3e5d2ebca8b5fe49e1 \ - --hash=sha256:aeb57c421b34af8f9fe830e1955bf493a86a7996cc1338fe41b30047d16e962c \ - --hash=sha256:ce785cf81a7bdade534297ef9e490ddff800d956625020ab2ec2780a556c313e \ - --hash=sha256:d0d651aa754ef58d75cec6edfbd21259d93810b73f6ec246436a21b7841908de +cryptography==41.0.6 \ + --hash=sha256:068bc551698c234742c40049e46840843f3d98ad7ce265fd2bd4ec0d11306596 \ + --hash=sha256:0f27acb55a4e77b9be8d550d762b0513ef3fc658cd3eb15110ebbcbd626db12c \ + --hash=sha256:2132d5865eea673fe6712c2ed5fb4fa49dba10768bb4cc798345748380ee3660 \ + --hash=sha256:3288acccef021e3c3c10d58933f44e8602cf04dba96d9796d70d537bb2f4bbc4 \ + --hash=sha256:35f3f288e83c3f6f10752467c48919a7a94b7d88cc00b0668372a0d2ad4f8ead \ + --hash=sha256:398ae1fc711b5eb78e977daa3cbf47cec20f2c08c5da129b7a296055fbb22aed \ + --hash=sha256:422e3e31d63743855e43e5a6fcc8b4acab860f560f9321b0ee6269cc7ed70cc3 \ + --hash=sha256:48783b7e2bef51224020efb61b42704207dde583d7e371ef8fc2a5fb6c0aabc7 \ + --hash=sha256:4d03186af98b1c01a4eda396b137f29e4e3fb0173e30f885e27acec8823c1b09 \ + --hash=sha256:5daeb18e7886a358064a68dbcaf441c036cbdb7da52ae744e7b9207b04d3908c \ + --hash=sha256:60e746b11b937911dc70d164060d28d273e31853bb359e2b2033c9e93e6f3c43 \ + --hash=sha256:742ae5e9a2310e9dade7932f9576606836ed174da3c7d26bc3d3ab4bd49b9f65 \ + --hash=sha256:7e00fb556bda398b99b0da289ce7053639d33b572847181d6483ad89835115f6 \ + --hash=sha256:85abd057699b98fce40b41737afb234fef05c67e116f6f3650782c10862c43da \ + --hash=sha256:8efb2af8d4ba9dbc9c9dd8f04d19a7abb5b49eab1f3694e7b5a16a5fc2856f5c \ + --hash=sha256:ae236bb8760c1e55b7a39b6d4d32d2279bc6c7c8500b7d5a13b6fb9fc97be35b \ + --hash=sha256:afda76d84b053923c27ede5edc1ed7d53e3c9f475ebaf63c68e69f1403c405a8 \ + --hash=sha256:b27a7fd4229abef715e064269d98a7e2909ebf92eb6912a9603c7e14c181928c \ + --hash=sha256:b648fe2a45e426aaee684ddca2632f62ec4613ef362f4d681a9a6283d10e079d \ + --hash=sha256:c5a550dc7a3b50b116323e3d376241829fd326ac47bc195e04eb33a8170902a9 \ + --hash=sha256:da46e2b5df770070412c46f87bac0849b8d685c5f2679771de277a422c7d0b86 \ + --hash=sha256:f39812f70fc5c71a15aa3c97b2bbe213c3f2a460b79bd21c40d033bb34a9bf36 \ + --hash=sha256:ff369dd19e8fe0528b02e8df9f2aeb2479f89b1270d90f96a63500afe9af5cae # via # gcp-releasetool # secretstorage diff --git a/CHANGELOG.md b/CHANGELOG.md index 88197b2c12..ea4a0271a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## [2.37.0](https://github.com/googleapis/java-bigquery/compare/v2.36.0...v2.37.0) (2024-01-25) + + +### Features + +* Add support for Table resource tags ([#3046](https://github.com/googleapis/java-bigquery/issues/3046)) ([7d61111](https://github.com/googleapis/java-bigquery/commit/7d61111d23282c7e2478ac31ba0d4e423330ec92)) +* Add universe domain ([#3090](https://github.com/googleapis/java-bigquery/issues/3090)) ([b2814a2](https://github.com/googleapis/java-bigquery/commit/b2814a2f8e6601347d0489058e563878af40f301)) + + +### Dependencies + +* Update actions/upload-artifact action to v4.1.0 ([#3071](https://github.com/googleapis/java-bigquery/issues/3071)) ([3fbb2bb](https://github.com/googleapis/java-bigquery/commit/3fbb2bba7ad7bca245a8ca5eb59d999aead29ebd)) +* Update actions/upload-artifact action to v4.2.0 ([#3081](https://github.com/googleapis/java-bigquery/issues/3081)) ([af81354](https://github.com/googleapis/java-bigquery/commit/af81354c342cdb2a790cb008fc9fe3460e62265b)) +* Update actions/upload-artifact action to v4.3.0 ([#3091](https://github.com/googleapis/java-bigquery/issues/3091)) ([f4411b0](https://github.com/googleapis/java-bigquery/commit/f4411b09c4b681d2f3fb250ef133b291649f2865)) +* Update arrow.version to v15 ([#3084](https://github.com/googleapis/java-bigquery/issues/3084)) ([4d4cbae](https://github.com/googleapis/java-bigquery/commit/4d4cbae00028f84c071f51e88d7ee976efdf04d5)) +* Update dependency com.google.api.grpc:proto-google-cloud-bigqueryconnection-v1 to v2.35.0 ([#3066](https://github.com/googleapis/java-bigquery/issues/3066)) ([48cdaa8](https://github.com/googleapis/java-bigquery/commit/48cdaa8a77935062cfe9ed8fb66f52f774bdd673)) +* Update dependency com.google.api.grpc:proto-google-cloud-bigqueryconnection-v1 to v2.36.0 ([#3093](https://github.com/googleapis/java-bigquery/issues/3093)) ([24456a3](https://github.com/googleapis/java-bigquery/commit/24456a361a39550e962ac68a79de3c7a9e912884)) +* Update dependency com.google.apis:google-api-services-bigquery to v2-rev20240105-2.0.0 ([#3073](https://github.com/googleapis/java-bigquery/issues/3073)) ([f371d67](https://github.com/googleapis/java-bigquery/commit/f371d6709109acf07224ee0b2615de400fd90838)) +* Update dependency com.google.cloud:google-cloud-datacatalog-bom to v1.39.0 ([#3067](https://github.com/googleapis/java-bigquery/issues/3067)) ([6ff4f04](https://github.com/googleapis/java-bigquery/commit/6ff4f043905a6fe67bc3ed5cbbacc0f9eddd3172)) +* Update dependency com.google.cloud:google-cloud-datacatalog-bom to v1.40.0 ([#3094](https://github.com/googleapis/java-bigquery/issues/3094)) ([110bcc5](https://github.com/googleapis/java-bigquery/commit/110bcc506272b372fdd90ee718fad298c8ab7e19)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.22.0 ([#3080](https://github.com/googleapis/java-bigquery/issues/3080)) ([a5b119c](https://github.com/googleapis/java-bigquery/commit/a5b119cdf6f8ce9d180a2d51a3a7a9aad50b1ea4)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.23.0 ([#3096](https://github.com/googleapis/java-bigquery/issues/3096)) ([0933b34](https://github.com/googleapis/java-bigquery/commit/0933b34f30ade216dcf61767a771509ca07f294b)) +* Update dependency com.google.oauth-client:google-oauth-client-java6 to v1.35.0 ([#3078](https://github.com/googleapis/java-bigquery/issues/3078)) ([2614df2](https://github.com/googleapis/java-bigquery/commit/2614df203b1f3c9800b8c8c23d32e7f22ec76253)) +* Update dependency com.google.oauth-client:google-oauth-client-jetty to v1.35.0 ([#3079](https://github.com/googleapis/java-bigquery/issues/3079)) ([f03c4fc](https://github.com/googleapis/java-bigquery/commit/f03c4fc957ae5665fe0f98c0f06cc80eea7cec59)) +* Update github/codeql-action action to v2.23.0 ([#3061](https://github.com/googleapis/java-bigquery/issues/3061)) ([0fbdfba](https://github.com/googleapis/java-bigquery/commit/0fbdfba1aecf18567fae95aea133b6504f050bd5)) +* Update github/codeql-action action to v2.23.1 ([#3077](https://github.com/googleapis/java-bigquery/issues/3077)) ([e3f417c](https://github.com/googleapis/java-bigquery/commit/e3f417cec3bdd81040baac3f054d0270dde9d9f8)) + ## [2.36.0](https://github.com/googleapis/java-bigquery/compare/v2.35.0...v2.36.0) (2024-01-10) diff --git a/README.md b/README.md index 0a5c250aec..9614c18ddf 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ If you are using Maven without the BOM, add this to your dependencies: com.google.cloud google-cloud-bigquery - 2.35.0 + 2.36.0 ``` @@ -53,20 +53,20 @@ If you are using Maven without the 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:26.29.0') +implementation platform('com.google.cloud:libraries-bom:26.30.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.35.0' +implementation 'com.google.cloud:google-cloud-bigquery:2.36.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.35.0" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.36.0" ``` @@ -351,7 +351,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.35.0 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.36.0 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 4041a1b706..54c64e8e41 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -6,7 +6,7 @@ google-cloud-bigquery-parent com.google.cloud - 2.36.0 + 2.37.0 diff --git a/google-cloud-bigquery/clirr-ignored-differences.xml b/google-cloud-bigquery/clirr-ignored-differences.xml index 7513b53240..9c69fd6a68 100644 --- a/google-cloud-bigquery/clirr-ignored-differences.xml +++ b/google-cloud-bigquery/clirr-ignored-differences.xml @@ -29,6 +29,11 @@ com/google/cloud/bigquery/RoutineInfo* *RemoteFunctionOptions(*) + + 7013 + com/google/cloud/bigquery/TableInfo* + *ResourceTags(*) + 7012 com/google/cloud/bigquery/Connection diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml index d7e1519367..c59d4be0d5 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.36.0 + 2.37.0 jar BigQuery https://github.com/googleapis/java-bigquery @@ -11,7 +11,7 @@ com.google.cloud google-cloud-bigquery-parent - 2.36.0 + 2.37.0 google-cloud-bigquery diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Labels.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Annotations.java similarity index 87% rename from google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Labels.java rename to google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Annotations.java index 8f91aa37ae..5d8d1e7e0c 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Labels.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Annotations.java @@ -28,9 +28,9 @@ import javax.annotation.Nullable; @AutoValue -abstract class Labels implements Serializable { +abstract class Annotations implements Serializable { private static final long serialVersionUID = 1L; - static final Labels ZERO = of(Collections.emptyMap()); + static final Annotations ZERO = of(Collections.emptyMap()); @Nullable abstract Map userMap(); @@ -59,13 +59,13 @@ Map toPb() { return Collections.unmodifiableMap(pbMap); } - private static Labels of(Map userMap) { + private static Annotations of(Map userMap) { Preconditions.checkArgument( userMap == null || !userMap.containsKey(null), "null keys are not supported"); - return new AutoValue_Labels(userMap); + return new AutoValue_Annotations(userMap); } - static Labels fromUser(Map map) { + static Annotations fromUser(Map map) { if (map == null || map instanceof ImmutableMap) { return of(map); } @@ -73,7 +73,7 @@ static Labels fromUser(Map map) { return of(Collections.unmodifiableMap(new HashMap<>(map))); } - static Labels fromPb(Map pb) { + static Annotations fromPb(Map pb) { if (Data.isNull(pb)) { return of(null); } diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/DatasetInfo.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/DatasetInfo.java index 0dddc0e86f..b5fabe97d1 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/DatasetInfo.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/DatasetInfo.java @@ -69,7 +69,7 @@ public Dataset apply(DatasetInfo datasetInfo) { private final Long lastModified; private final String location; private final String selfLink; - private final Labels labels; + private final Annotations labels; private final EncryptionConfiguration defaultEncryptionConfiguration; private final Long defaultPartitionExpirationMs; private final String defaultCollation; @@ -194,7 +194,7 @@ static final class BuilderImpl extends Builder { private Long lastModified; private String location; private String selfLink; - private Labels labels = Labels.ZERO; + private Annotations labels = Annotations.ZERO; private EncryptionConfiguration defaultEncryptionConfiguration; private Long defaultPartitionExpirationMs; private String defaultCollation; @@ -247,7 +247,7 @@ public Acl apply(Dataset.Access accessPb) { this.lastModified = datasetPb.getLastModifiedTime(); this.location = datasetPb.getLocation(); this.selfLink = datasetPb.getSelfLink(); - this.labels = Labels.fromPb(datasetPb.getLabels()); + this.labels = Annotations.fromPb(datasetPb.getLabels()); if (datasetPb.getDefaultEncryptionConfiguration() != null) { this.defaultEncryptionConfiguration = new EncryptionConfiguration.Builder(datasetPb.getDefaultEncryptionConfiguration()) @@ -337,7 +337,7 @@ Builder setSelfLink(String selfLink) { */ @Override public Builder setLabels(Map labels) { - this.labels = Labels.fromUser(labels); + this.labels = Annotations.fromUser(labels); return this; } diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ModelInfo.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ModelInfo.java index 83603cbd23..922ed441c8 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ModelInfo.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ModelInfo.java @@ -67,7 +67,7 @@ public Model apply(ModelInfo ModelInfo) { private final Long creationTime; private final Long lastModifiedTime; private final Long expirationTime; - private final Labels labels; + private final Annotations labels; private final String location; private final ImmutableList trainingRunList; private final ImmutableList featureColumnList; @@ -132,7 +132,7 @@ static class BuilderImpl extends Builder { private Long creationTime; private Long lastModifiedTime; private Long expirationTime; - private Labels labels = Labels.ZERO; + private Annotations labels = Annotations.ZERO; private String location; private List trainingRunList = Collections.emptyList(); private List labelColumnList = Collections.emptyList(); @@ -169,7 +169,7 @@ static class BuilderImpl extends Builder { this.creationTime = modelPb.getCreationTime(); this.lastModifiedTime = modelPb.getLastModifiedTime(); this.expirationTime = modelPb.getExpirationTime(); - this.labels = Labels.fromPb(modelPb.getLabels()); + this.labels = Annotations.fromPb(modelPb.getLabels()); this.location = modelPb.getLocation(); if (modelPb.getTrainingRuns() != null) { this.trainingRunList = modelPb.getTrainingRuns(); @@ -238,7 +238,7 @@ public Builder setModelId(ModelId modelId) { @Override public Builder setLabels(Map labels) { - this.labels = Labels.fromUser(labels); + this.labels = Annotations.fromUser(labels); return this; } diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java index fdf0bad668..56c6558555 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java @@ -192,6 +192,12 @@ public Builder setLabels(Map labels) { return this; } + @Override + public Builder setResourceTags(Map resourceTags) { + infoBuilder.setResourceTags(resourceTags); + return this; + } + @Override public Builder setRequirePartitionFilter(Boolean requirePartitionFilter) { infoBuilder.setRequirePartitionFilter(requirePartitionFilter); diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableInfo.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableInfo.java index c00ba84410..6e050d0649 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableInfo.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableInfo.java @@ -77,7 +77,9 @@ public Table apply(TableInfo tableInfo) { private final BigInteger numRows; private final TableDefinition definition; private final EncryptionConfiguration encryptionConfiguration; - private final Labels labels; + private final Annotations labels; + + private final Annotations resourceTags; private final Boolean requirePartitionFilter; private final String defaultCollation; @@ -152,6 +154,9 @@ public abstract static class Builder { @BetaApi public abstract Builder setLabels(Map labels); + /** Sets the resource tags applied to this table. */ + public abstract Builder setResourceTags(Map resourceTags); + /** Creates a {@code TableInfo} object. */ public abstract TableInfo build(); @@ -191,7 +196,9 @@ static class BuilderImpl extends Builder { private BigInteger numRows; private TableDefinition definition; private EncryptionConfiguration encryptionConfiguration; - private Labels labels = Labels.ZERO; + private Annotations labels = Annotations.ZERO; + + private Annotations resourceTags = Annotations.ZERO; private Boolean requirePartitionFilter; private String defaultCollation; private CloneDefinition cloneDefinition; @@ -222,6 +229,7 @@ static class BuilderImpl extends Builder { this.definition = tableInfo.definition; this.encryptionConfiguration = tableInfo.encryptionConfiguration; this.labels = tableInfo.labels; + this.resourceTags = tableInfo.resourceTags; this.requirePartitionFilter = tableInfo.requirePartitionFilter; this.defaultCollation = tableInfo.defaultCollation; this.cloneDefinition = tableInfo.cloneDefinition; @@ -255,7 +263,8 @@ static class BuilderImpl extends Builder { this.encryptionConfiguration = new EncryptionConfiguration.Builder(tablePb.getEncryptionConfiguration()).build(); } - this.labels = Labels.fromPb(tablePb.getLabels()); + this.labels = Annotations.fromPb(tablePb.getLabels()); + this.resourceTags = Annotations.fromPb(tablePb.getResourceTags()); this.requirePartitionFilter = tablePb.getRequirePartitionFilter(); this.defaultCollation = tablePb.getDefaultCollation(); if (tablePb.getCloneDefinition() != null) { @@ -394,7 +403,13 @@ public Builder setEncryptionConfiguration(EncryptionConfiguration configuration) @Override public Builder setLabels(Map labels) { - this.labels = Labels.fromUser(labels); + this.labels = Annotations.fromUser(labels); + return this; + } + + @Override + public Builder setResourceTags(Map resourceTags) { + this.resourceTags = Annotations.fromUser(resourceTags); return this; } @@ -449,6 +464,7 @@ public TableInfo build() { this.definition = builder.definition; this.encryptionConfiguration = builder.encryptionConfiguration; this.labels = builder.labels; + this.resourceTags = builder.resourceTags; this.requirePartitionFilter = builder.requirePartitionFilter; this.defaultCollation = builder.defaultCollation; this.cloneDefinition = builder.cloneDefinition; @@ -610,6 +626,11 @@ public Map getLabels() { return labels.userMap(); } + /** Return a map for resource tags applied to the table. */ + public Map getResourceTags() { + return resourceTags.userMap(); + } + /** * Returns true if a partition filter (that can be used for partition elimination) is required for * queries over this table. @@ -660,6 +681,7 @@ public String toString() { .add("definition", definition) .add("encryptionConfiguration", encryptionConfiguration) .add("labels", labels) + .add("resourceTags", resourceTags) .add("requirePartitionFilter", requirePartitionFilter) .add("defaultCollation", defaultCollation) .add("cloneDefinition", cloneDefinition) @@ -724,6 +746,7 @@ Table toPb() { tablePb.setEncryptionConfiguration(encryptionConfiguration.toPb()); } tablePb.setLabels(labels.toPb()); + tablePb.setResourceTags(resourceTags.toPb()); tablePb.setRequirePartitionFilter(requirePartitionFilter); if (defaultCollation != null) { tablePb.setDefaultCollation(defaultCollation); diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java index 96a10deb33..841a790ee6 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java @@ -105,7 +105,7 @@ public HttpBigQueryRpc(BigQueryOptions options) { this.options = options; bigquery = new Bigquery.Builder(transport, new GsonFactory(), initializer) - .setRootUrl(options.getHost()) + .setRootUrl(options.getResolvedApiaryHost("bigquery")) .setApplicationName(options.getApplicationName()) .build(); } @@ -114,9 +114,16 @@ private static BigQueryException translate(IOException exception) { return new BigQueryException(exception); } + private void validateRPC() throws BigQueryException, IOException { + if (!this.options.hasValidUniverseDomain()) { + throw new BigQueryException(BigQueryException.UNKNOWN_CODE, "Invalid universe domain"); + } + } + @Override public Dataset getDataset(String projectId, String datasetId, Map options) { try { + validateRPC(); return bigquery .datasets() .get(projectId, datasetId) @@ -135,6 +142,7 @@ public Dataset getDataset(String projectId, String datasetId, Map opt @Override public Tuple> listDatasets(String projectId, Map options) { try { + validateRPC(); DatasetList datasetsList = bigquery .datasets() @@ -159,6 +167,7 @@ public Tuple> listDatasets(String projectId, Map options) { try { + validateRPC(); return bigquery .datasets() .insert(dataset.getDatasetReference().getProjectId(), dataset) @@ -173,6 +182,7 @@ public Dataset create(Dataset dataset, Map options) { @Override public Table create(Table table, Map options) { try { + validateRPC(); // unset the type, as it is output only table.setType(null); TableReference reference = table.getTableReference(); @@ -190,6 +200,7 @@ public Table create(Table table, Map options) { @Override public Routine create(Routine routine, Map options) { try { + validateRPC(); RoutineReference reference = routine.getRoutineReference(); return bigquery .routines() @@ -205,6 +216,7 @@ public Routine create(Routine routine, Map options) { @Override public Job create(Job job, Map options) { try { + validateRPC(); String projectId = job.getJobReference() != null ? job.getJobReference().getProjectId() @@ -223,6 +235,7 @@ public Job create(Job job, Map options) { @Override public Job createJobForQuery(Job job) { try { + validateRPC(); String projectId = job.getJobReference() != null ? job.getJobReference().getProjectId() @@ -236,6 +249,7 @@ public Job createJobForQuery(Job job) { @Override public boolean deleteDataset(String projectId, String datasetId, Map options) { try { + validateRPC(); bigquery .datasets() .delete(projectId, datasetId) @@ -255,6 +269,7 @@ public boolean deleteDataset(String projectId, String datasetId, Map @Override public Dataset patch(Dataset dataset, Map options) { try { + validateRPC(); DatasetReference reference = dataset.getDatasetReference(); return bigquery .datasets() @@ -270,6 +285,7 @@ public Dataset patch(Dataset dataset, Map options) { @Override public Table patch(Table table, Map options) { try { + validateRPC(); // unset the type, as it is output only table.setType(null); TableReference reference = table.getTableReference(); @@ -289,6 +305,7 @@ public Table patch(Table table, Map options) { public Table getTable( String projectId, String datasetId, String tableId, Map options) { try { + validateRPC(); return bigquery .tables() .get(projectId, datasetId, tableId) @@ -316,6 +333,7 @@ private String getTableMetadataOption(Map options) { public Tuple> listTables( String projectId, String datasetId, Map options) { try { + validateRPC(); TableList tableList = bigquery .tables() @@ -351,6 +369,7 @@ public Table apply(TableList.Tables tablePb) { @Override public boolean deleteTable(String projectId, String datasetId, String tableId) { try { + validateRPC(); bigquery.tables().delete(projectId, datasetId, tableId).execute(); return true; } catch (IOException ex) { @@ -365,6 +384,7 @@ public boolean deleteTable(String projectId, String datasetId, String tableId) { @Override public Model patch(Model model, Map options) { try { + validateRPC(); // unset the type, as it is output only ModelReference reference = model.getModelReference(); return bigquery @@ -382,6 +402,7 @@ public Model patch(Model model, Map options) { public Model getModel( String projectId, String datasetId, String modelId, Map options) { try { + validateRPC(); return bigquery .models() .get(projectId, datasetId, modelId) @@ -401,6 +422,7 @@ public Model getModel( public Tuple> listModels( String projectId, String datasetId, Map options) { try { + validateRPC(); ListModelsResponse modelList = bigquery .models() @@ -420,6 +442,7 @@ public Tuple> listModels( @Override public boolean deleteModel(String projectId, String datasetId, String modelId) { try { + validateRPC(); bigquery.models().delete(projectId, datasetId, modelId).execute(); return true; } catch (IOException ex) { @@ -434,6 +457,7 @@ public boolean deleteModel(String projectId, String datasetId, String modelId) { @Override public Routine update(Routine routine, Map options) { try { + validateRPC(); RoutineReference reference = routine.getRoutineReference(); return bigquery .routines() @@ -451,6 +475,7 @@ public Routine update(Routine routine, Map options) { public Routine getRoutine( String projectId, String datasetId, String routineId, Map options) { try { + validateRPC(); return bigquery .routines() .get(projectId, datasetId, routineId) @@ -470,6 +495,7 @@ public Routine getRoutine( public Tuple> listRoutines( String projectId, String datasetId, Map options) { try { + validateRPC(); ListRoutinesResponse routineList = bigquery .routines() @@ -491,6 +517,7 @@ public Tuple> listRoutines( @Override public boolean deleteRoutine(String projectId, String datasetId, String routineId) { try { + validateRPC(); bigquery.routines().delete(projectId, datasetId, routineId).execute(); return true; } catch (IOException ex) { @@ -506,6 +533,7 @@ public boolean deleteRoutine(String projectId, String datasetId, String routineI public TableDataInsertAllResponse insertAll( String projectId, String datasetId, String tableId, TableDataInsertAllRequest request) { try { + validateRPC(); return bigquery .tabledata() .insertAll(projectId, datasetId, tableId, request) @@ -520,6 +548,7 @@ public TableDataInsertAllResponse insertAll( public TableDataList listTableData( String projectId, String datasetId, String tableId, Map options) { try { + validateRPC(); return bigquery .tabledata() .list(projectId, datasetId, tableId) @@ -544,6 +573,7 @@ public TableDataList listTableDataWithRowLimit( Integer maxResultPerPage, String pageToken) { try { + validateRPC(); return bigquery .tabledata() .list(projectId, datasetId, tableId) @@ -559,6 +589,7 @@ public TableDataList listTableDataWithRowLimit( @Override public Job getJob(String projectId, String jobId, String location, Map options) { try { + validateRPC(); return bigquery .jobs() .get(projectId, jobId) @@ -578,6 +609,7 @@ public Job getJob(String projectId, String jobId, String location, Map> listJobs(String projectId, Map options) { try { + validateRPC(); Bigquery.Jobs.List request = bigquery .jobs() @@ -650,6 +683,7 @@ public Job apply(JobList.Jobs jobPb) { @Override public boolean cancel(String projectId, String jobId, String location) { try { + validateRPC(); bigquery .jobs() .cancel(projectId, jobId) @@ -669,6 +703,7 @@ public boolean cancel(String projectId, String jobId, String location) { @Override public boolean deleteJob(String projectId, String jobName, String location) { try { + validateRPC(); bigquery .jobs() .delete(projectId, jobName) @@ -685,6 +720,7 @@ public boolean deleteJob(String projectId, String jobName, String location) { public GetQueryResultsResponse getQueryResults( String projectId, String jobId, String location, Map options) { try { + validateRPC(); return bigquery .jobs() .getQueryResults(projectId, jobId) @@ -707,6 +743,7 @@ public GetQueryResultsResponse getQueryResults( public GetQueryResultsResponse getQueryResultsWithRowLimit( String projectId, String jobId, String location, Integer maxResultPerPage, Long timeoutMs) { try { + validateRPC(); return bigquery .jobs() .getQueryResults(projectId, jobId) @@ -723,6 +760,7 @@ public GetQueryResultsResponse getQueryResultsWithRowLimit( @Override public QueryResponse queryRpc(String projectId, QueryRequest content) { try { + validateRPC(); return bigquery.jobs().query(projectId, content).execute(); } catch (IOException ex) { throw translate(ex); @@ -732,7 +770,7 @@ public QueryResponse queryRpc(String projectId, QueryRequest content) { @Override public String open(Job loadJob) { try { - String builder = options.getHost(); + String builder = options.getResolvedApiaryHost("bigquery"); if (!builder.endsWith("/")) { builder += "/"; } @@ -807,6 +845,7 @@ public Job write( @Override public Policy getIamPolicy(String resourceId, Map options) { try { + validateRPC(); GetIamPolicyRequest policyRequest = new GetIamPolicyRequest(); if (null != Option.REQUESTED_POLICY_VERSION.getLong(options)) { policyRequest = @@ -828,6 +867,7 @@ public Policy getIamPolicy(String resourceId, Map options) { @Override public Policy setIamPolicy(String resourceId, Policy policy, Map options) { try { + validateRPC(); SetIamPolicyRequest policyRequest = new SetIamPolicyRequest().setPolicy(policy); return bigquery .tables() @@ -843,6 +883,7 @@ public Policy setIamPolicy(String resourceId, Policy policy, Map opti public TestIamPermissionsResponse testIamPermissions( String resourceId, List permissions, Map options) { try { + validateRPC(); TestIamPermissionsRequest permissionsRequest = new TestIamPermissionsRequest().setPermissions(permissions); return bigquery diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LabelsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java similarity index 62% rename from google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LabelsTest.java rename to google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java index 787dd77df7..aa3dd9fde4 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LabelsTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java @@ -25,50 +25,50 @@ import java.util.Map; import org.junit.Test; -public class LabelsTest { +public class AnnotationsTest { @Test public void testFromUser() { - assertThat(Labels.fromUser(null).userMap()).isNull(); + assertThat(Annotations.fromUser(null).userMap()).isNull(); HashMap user = new HashMap<>(); - assertThat(Labels.fromUser(user).userMap()).isEmpty(); + assertThat(Annotations.fromUser(user).userMap()).isEmpty(); user.put("a", "b"); - Labels labels = Labels.fromUser(user); - assertThat(labels.userMap()).containsExactly("a", "b"); + Annotations annotations = Annotations.fromUser(user); + assertThat(annotations.userMap()).containsExactly("a", "b"); - // Changing map afterwards does not change the labels. + // Changing map afterwards does not change the annotation. user.put("c", "d"); - assertThat(labels.userMap()).containsExactly("a", "b"); + assertThat(annotations.userMap()).containsExactly("a", "b"); } @Test public void testFromToPb() { - assertThat(Labels.fromPb(null).toPb()).isNull(); + assertThat(Annotations.fromPb(null).toPb()).isNull(); HashMap pb = new HashMap<>(); - assertThat(Labels.fromPb(pb).toPb()).isNull(); + assertThat(Annotations.fromPb(pb).toPb()).isNull(); pb.put("a", "b"); - assertThat(Labels.fromPb(pb).toPb()).isEqualTo(pb); + assertThat(Annotations.fromPb(pb).toPb()).isEqualTo(pb); pb.put("c", Data.NULL_STRING); - assertThat(Labels.fromPb(pb).toPb()).isEqualTo(pb); + assertThat(Annotations.fromPb(pb).toPb()).isEqualTo(pb); Map jsonNullMap = Data.nullOf(HashMap.class); - assertThat(Data.isNull(Labels.fromPb(jsonNullMap).toPb())).isTrue(); + assertThat(Data.isNull(Annotations.fromPb(jsonNullMap).toPb())).isTrue(); } @Test public void testNullKey() { try { - Labels.fromUser(Collections.singletonMap((String) null, "foo")); + Annotations.fromUser(Collections.singletonMap((String) null, "foo")); fail("null key shouldn't work"); } catch (IllegalArgumentException e) { } try { - Labels.fromPb(Collections.singletonMap((String) null, "foo")); + Annotations.fromPb(Collections.singletonMap((String) null, "foo")); fail("null key shouldn't work"); } catch (IllegalArgumentException e) { } diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java index 6283f71c21..a4ce6fbb47 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java @@ -126,6 +126,7 @@ public class TableInfoTest { .setNumRows(BigInteger.valueOf(NUM_ROWS)) .setSelfLink(SELF_LINK) .setLabels(Collections.singletonMap("a", "b")) + .setResourceTags(Collections.singletonMap("resourceTagA", "resourceTagB")) .setRequirePartitionFilter(REQUIRE_PARTITION_FILTER) .build(); private static final TableInfo VIEW_INFO = @@ -309,6 +310,7 @@ private void compareTableInfo(TableInfo expected, TableInfo value) { assertEquals(expected.getNumRows(), value.getNumRows()); assertEquals(expected.getSelfLink(), value.getSelfLink()); assertEquals(expected.getLabels(), value.getLabels()); + assertEquals(expected.getResourceTags(), value.getResourceTags()); assertEquals(expected.getRequirePartitionFilter(), value.getRequirePartitionFilter()); assertEquals(expected.toString(), value.toString()); assertEquals(expected.hashCode(), value.hashCode()); 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 d8d673360d..ba30ea0d43 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 @@ -54,6 +54,7 @@ import com.google.cloud.bigquery.BigQueryDryRunResult; import com.google.cloud.bigquery.BigQueryError; import com.google.cloud.bigquery.BigQueryException; +import com.google.cloud.bigquery.BigQueryOptions; import com.google.cloud.bigquery.BigQueryResult; import com.google.cloud.bigquery.BigQuerySQLException; import com.google.cloud.bigquery.CloneDefinition; @@ -149,6 +150,7 @@ import com.google.common.io.BaseEncoding; import com.google.common.util.concurrent.ListenableFuture; import com.google.gson.JsonObject; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -773,6 +775,65 @@ public class ITBigQueryTest { private static final String PUBLIC_PROJECT = "bigquery-public-data"; private static final String PUBLIC_DATASET = "census_bureau_international"; + private static final String FAKE_JSON_CRED_WITH_GOOGLE_DOMAIN = + "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"project_id\": \"someprojectid\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\",\n" + + " \"universe_domain\": \"googleapis.com\"\n" + + "}"; + private static final String FAKE_JSON_CRED_WITH_INVALID_DOMAIN = + "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"project_id\": \"someprojectid\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\",\n" + + " \"universe_domain\": \"fake.domain\"\n" + + "}"; + private static BigQuery bigquery; private static Storage storage; @@ -6323,4 +6384,77 @@ public void testStatelessQueriesWithLocation() throws Exception { bigQuery.delete(dataset.getDatasetId(), DatasetDeleteOption.deleteContents()); } } + + @Test + public void testUniverseDomainWithInvalidUniverseDomain() { + RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create(); + BigQueryOptions bigQueryOptions = + bigqueryHelper + .getOptions() + .toBuilder() + .setCredentials(loadCredentials(FAKE_JSON_CRED_WITH_GOOGLE_DOMAIN)) + .setUniverseDomain("invalid.domain") + .build(); + BigQuery bigQuery = bigQueryOptions.getService(); + + try { + // Use list dataset to send RPC to invalid domain. + bigQuery.listDatasets("bigquery-public-data"); + fail("RPCs to invalid universe domain should fail"); + } catch (BigQueryException e) { + assertNotNull(e.getMessage()); + assertThat((e.getMessage().contains("Invalid universe domain"))).isTrue(); + } + } + + @Test + public void testInvalidUniverseDomainWithMismatchCredentials() { + RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create(); + BigQueryOptions bigQueryOptions = + bigqueryHelper + .getOptions() + .toBuilder() + .setCredentials(loadCredentials(FAKE_JSON_CRED_WITH_INVALID_DOMAIN)) + .build(); + BigQuery bigQuery = bigQueryOptions.getService(); + + try { + // Use list dataset to send RPC to invalid domain. + bigQuery.listDatasets("bigquery-public-data"); + fail("RPCs to invalid universe domain should fail"); + } catch (BigQueryException e) { + assertNotNull(e.getMessage()); + assertThat((e.getMessage().contains("Invalid universe domain"))).isTrue(); + } + } + + @Test + public void testUniverseDomainWithMatchingDomain() { + // Test a valid domain using the default credentials and Google default universe domain. + RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create(); + BigQueryOptions bigQueryOptions = + bigqueryHelper.getOptions().toBuilder().setUniverseDomain("googleapis.com").build(); + BigQuery bigQuery = bigQueryOptions.getService(); + + // Verify that all is well by listing a dataset. + Page datasets = bigQuery.listDatasets("bigquery-public-data"); + Iterator iterator = datasets.iterateAll().iterator(); + Set datasetNames = new HashSet<>(); + while (iterator.hasNext()) { + datasetNames.add(iterator.next().getDatasetId().getDataset()); + } + for (String type : PUBLIC_DATASETS) { + assertTrue(datasetNames.contains(type)); + } + } + + static GoogleCredentials loadCredentials(String credentialFile) { + try { + InputStream keyStream = new ByteArrayInputStream(credentialFile.getBytes()); + return GoogleCredentials.fromStream(keyStream); + } catch (IOException e) { + fail("Couldn't create fake JSON credentials."); + } + return null; + } } diff --git a/pom.xml b/pom.xml index f7c83573fe..c22acba483 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-bigquery-parent pom - 2.36.0 + 2.37.0 BigQuery Parent https://github.com/googleapis/java-bigquery @@ -54,9 +54,9 @@ UTF-8 github google-cloud-bigquery-parent - v2-rev20231111-2.0.0 - 3.21.0 - 14.0.2 + v2-rev20240105-2.0.0 + 3.23.0 + 15.0.0 @@ -73,7 +73,7 @@ com.google.cloud google-cloud-bigquerystorage-bom - 2.47.0 + 3.0.1 pom import @@ -97,7 +97,7 @@ com.google.cloud google-cloud-datacatalog-bom - 1.36.0 + 1.40.0 pom import @@ -111,7 +111,7 @@ com.google.cloud google-cloud-bigquery - 2.36.0 + 2.37.0 @@ -137,7 +137,7 @@ com.google.truth truth - 1.2.0 + 1.3.0 test @@ -155,19 +155,19 @@ com.google.cloud google-cloud-storage - 2.31.0 + 2.32.1 test com.google.cloud google-cloud-bigqueryconnection - 2.34.0 + 2.36.0 test com.google.api.grpc proto-google-cloud-bigqueryconnection-v1 - 2.34.0 + 2.36.0 test diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 99e3a85400..de976d88ab 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -45,31 +45,31 @@ com.google.cloud google-cloud-bigquery - 2.35.0 + 2.36.0 com.google.oauth-client google-oauth-client-java6 - 1.34.1 + 1.35.0 com.google.oauth-client google-oauth-client-jetty - 1.34.1 + 1.35.0 com.google.cloud google-cloud-bigtable - 2.30.0 + 2.31.0 test com.google.cloud google-cloud-bigqueryconnection - 2.34.0 + 2.36.0 test @@ -81,7 +81,7 @@ com.google.truth truth - 1.2.0 + 1.3.0 test diff --git a/samples/native-image-sample/pom.xml b/samples/native-image-sample/pom.xml index 95de88cf6e..df62de7dc2 100644 --- a/samples/native-image-sample/pom.xml +++ b/samples/native-image-sample/pom.xml @@ -62,7 +62,7 @@ com.google.truth truth - 1.2.0 + 1.3.0 test @@ -111,7 +111,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.3 + 3.2.5 **/*IT diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index a38c313c7f..f96a2ed83f 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -44,30 +44,30 @@ com.google.cloud google-cloud-bigquery - 2.36.0 + 2.37.0 com.google.oauth-client google-oauth-client-java6 - 1.34.1 + 1.35.0 com.google.oauth-client google-oauth-client-jetty - 1.34.1 + 1.35.0 com.google.cloud google-cloud-bigtable - 2.30.0 + 2.31.0 test com.google.cloud google-cloud-bigqueryconnection - 2.34.0 + 2.36.0 test @@ -79,7 +79,7 @@ com.google.truth truth - 1.2.0 + 1.3.0 test diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 3debd229ed..732a9b53dd 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -66,12 +66,12 @@ com.google.oauth-client google-oauth-client-java6 - 1.34.1 + 1.35.0 com.google.oauth-client google-oauth-client-jetty - 1.34.1 + 1.35.0 @@ -79,13 +79,13 @@ com.google.cloud google-cloud-bigtable - 2.30.0 + 2.31.0 test com.google.cloud google-cloud-bigqueryconnection - 2.34.0 + 2.36.0 test @@ -97,7 +97,7 @@ com.google.truth truth - 1.2.0 + 1.3.0 test diff --git a/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java b/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java index 1aeaff1955..429a339cf5 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java +++ b/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java @@ -17,6 +17,7 @@ package com.example.bigquery; // [START bigquery_query] + import com.google.cloud.bigquery.BigQuery; import com.google.cloud.bigquery.BigQueryException; import com.google.cloud.bigquery.BigQueryOptions; @@ -27,7 +28,9 @@ public class SimpleQuery { public static void main(String[] args) { // TODO(developer): Replace this query before running the sample. - String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; + String query = + "SELECT corpus, count(*) as corpus_count " + + "FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; simpleQuery(query); } @@ -44,7 +47,14 @@ public static void simpleQuery(String query) { TableResult result = bigquery.query(queryConfig); // Print the results. - result.iterateAll().forEach(rows -> rows.forEach(row -> System.out.println(row.getValue()))); + result + .iterateAll() + .forEach( + row -> { + System.out.print("corpus:" + row.get("corpus").getStringValue()); + System.out.print(", count:" + row.get("corpus_count").getLongValue()); + System.out.println(); + }); System.out.println("Query ran successfully"); } catch (BigQueryException | InterruptedException e) { diff --git a/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java b/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java index b750c31464..5441ffccad 100644 --- a/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java +++ b/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java @@ -51,7 +51,9 @@ public void tearDown() { @Test public void testSimpleQuery() { - String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; + String query = + "SELECT corpus, count(*) as corpus_count " + + "FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; SimpleQuery.simpleQuery(query); assertThat(bout.toString()).contains("Query ran successfully"); diff --git a/versions.txt b/versions.txt index e2ab490a51..fc69e91467 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-bigquery:2.36.0:2.36.0 \ No newline at end of file +google-cloud-bigquery:2.37.0:2.37.0 \ No newline at end of file