diff --git a/CHANGELOG.md b/CHANGELOG.md index 56c529d65..849a6b119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [2.13.0](https://github.com/googleapis/java-bigquery/compare/v2.12.0...v2.13.0) (2022-05-31) + + +### Features + +* add destinationExpirationTime to CopyJobConfiguration ([#2031](https://github.com/googleapis/java-bigquery/issues/2031)) ([9e0b351](https://github.com/googleapis/java-bigquery/commit/9e0b35136aed6ed489bff4d4ac86c4d5d83274be)) + + +### Documentation + +* **samples:** update querypagination sample ([#2074](https://github.com/googleapis/java-bigquery/issues/2074)) ([4e153f5](https://github.com/googleapis/java-bigquery/commit/4e153f525cc600cecdfabec600b166560ba62607)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-datacatalog-bom to v1.8.1 ([#2076](https://github.com/googleapis/java-bigquery/issues/2076)) ([38d6bae](https://github.com/googleapis/java-bigquery/commit/38d6baefeebe0dc2858d38f6c44ad727b6beba92)) +* update dependency com.google.cloud:google-cloud-storage to v2.7.2 ([#2077](https://github.com/googleapis/java-bigquery/issues/2077)) ([eb443df](https://github.com/googleapis/java-bigquery/commit/eb443dfd5fd26e9c424dcbb1b00af5260a525679)) + ## [2.12.0](https://github.com/googleapis/java-bigquery/compare/v2.11.2...v2.12.0) (2022-05-25) diff --git a/README.md b/README.md index 0d2537d09..39d86d4d9 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-bigquery - 2.11.2 + 2.12.0 ``` @@ -59,13 +59,13 @@ 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.11.2' +implementation 'com.google.cloud:google-cloud-bigquery:2.12.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.11.2" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.12.0" ``` ## Authentication diff --git a/benchmark/pom.xml b/benchmark/pom.xml index b0d1afe97..93a03ee18 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -6,7 +6,7 @@ google-cloud-bigquery-parent com.google.cloud - 2.12.0 + 2.13.0 diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml index 1736ade47..ac898f783 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.12.0 + 2.13.0 jar BigQuery https://github.com/googleapis/java-bigquery @@ -11,7 +11,7 @@ com.google.cloud google-cloud-bigquery-parent - 2.12.0 + 2.13.0 google-cloud-bigquery diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/CopyJobConfiguration.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/CopyJobConfiguration.java index 0b11bf7be..fe67986fc 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/CopyJobConfiguration.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/CopyJobConfiguration.java @@ -39,6 +39,7 @@ public final class CopyJobConfiguration extends JobConfiguration { private final List sourceTables; private final TableId destinationTable; private final String operationType; + private final String destinationExpirationTime; private final JobInfo.CreateDisposition createDisposition; private final JobInfo.WriteDisposition writeDisposition; private final EncryptionConfiguration destinationEncryptionConfiguration; @@ -51,6 +52,7 @@ public static final class Builder private List sourceTables; private TableId destinationTable; private String operationType; + private String destinationExpirationTime; private JobInfo.CreateDisposition createDisposition; private JobInfo.WriteDisposition writeDisposition; private EncryptionConfiguration destinationEncryptionConfiguration; @@ -66,6 +68,7 @@ private Builder(CopyJobConfiguration jobConfiguration) { this.sourceTables = jobConfiguration.sourceTables; this.destinationTable = jobConfiguration.destinationTable; this.operationType = jobConfiguration.operationType; + this.destinationExpirationTime = jobConfiguration.destinationExpirationTime; this.createDisposition = jobConfiguration.createDisposition; this.writeDisposition = jobConfiguration.writeDisposition; this.destinationEncryptionConfiguration = jobConfiguration.destinationEncryptionConfiguration; @@ -80,6 +83,10 @@ private Builder(com.google.api.services.bigquery.model.JobConfiguration configur if (copyConfigurationPb.getOperationType() != null) { this.operationType = copyConfigurationPb.getOperationType(); } + if (copyConfigurationPb.getDestinationExpirationTime() != null) { + this.destinationExpirationTime = + copyConfigurationPb.getDestinationExpirationTime().toString(); + } if (copyConfigurationPb.getSourceTables() != null) { this.sourceTables = Lists.transform(copyConfigurationPb.getSourceTables(), TableId.FROM_PB_FUNCTION); @@ -129,6 +136,16 @@ public Builder setOperationType(String operationType) { return this; } + /** + * Sets the time when the destination table expires. Expired tables will be deleted and their + * storage reclaimed. More info: + * https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#jobconfigurationtablecopy + */ + public Builder setDestinationExpirationTime(String destinationExpirationTime) { + this.destinationExpirationTime = destinationExpirationTime; + return this; + } + public Builder setDestinationEncryptionConfiguration( EncryptionConfiguration encryptionConfiguration) { this.destinationEncryptionConfiguration = encryptionConfiguration; @@ -194,6 +211,7 @@ private CopyJobConfiguration(Builder builder) { this.sourceTables = checkNotNull(builder.sourceTables); this.destinationTable = checkNotNull(builder.destinationTable); this.operationType = builder.operationType; + this.destinationExpirationTime = builder.destinationExpirationTime; this.createDisposition = builder.createDisposition; this.writeDisposition = builder.writeDisposition; this.destinationEncryptionConfiguration = builder.destinationEncryptionConfiguration; @@ -216,6 +234,11 @@ public String getOperationType() { return operationType; } + /** Returns the time when the destination table expires */ + public String getDestinationExpirationTime() { + return destinationExpirationTime; + } + public EncryptionConfiguration getDestinationEncryptionConfiguration() { return destinationEncryptionConfiguration; } @@ -263,6 +286,7 @@ ToStringHelper toStringHelper() { .add("sourceTables", sourceTables) .add("destinationTable", destinationTable) .add("operationType", operationType) + .add("destinationExpirationTime", destinationExpirationTime) .add("destinationEncryptionConfiguration", destinationEncryptionConfiguration) .add("createDisposition", createDisposition) .add("writeDisposition", writeDisposition) @@ -283,6 +307,7 @@ public int hashCode() { sourceTables, destinationTable, operationType, + destinationExpirationTime, createDisposition, writeDisposition, labels, @@ -322,6 +347,9 @@ com.google.api.services.bigquery.model.JobConfiguration toPb() { if (operationType != null) { configurationPb.setOperationType(operationType); } + if (destinationExpirationTime != null) { + configurationPb.setDestinationExpirationTime(destinationExpirationTime); + } if (createDisposition != null) { configurationPb.setCreateDisposition(createDisposition.toString()); } 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 5b2b74ec0..812833d9c 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 @@ -2724,6 +2724,15 @@ public void testReadAPIIterationAndOrder() connection.close(); } + // Ref: https://github.com/googleapis/java-bigquery/issues/2070. Adding a pre-submit test to see + // if bigquery.createConnection() returns null + @Test + public void testCreateDefaultConnection() throws BigQuerySQLException { + Connection connection = bigquery.createConnection(); + assertNotNull("bigquery.createConnection() returned null", connection); + assertTrue(connection.close()); + } + @Test public void testReadAPIConnectionMultiClose() throws @@ -3884,7 +3893,8 @@ public void testSnapshotTableCopyJob() throws InterruptedException { } @Test - public void testCopyJobWithLabels() throws InterruptedException { + public void testCopyJobWithLabelsAndExpTime() throws InterruptedException { + String destExpiryTime = "2025-12-31T23:59:59.999999999Z"; String sourceTableName = "test_copy_job_source_table_label"; String destinationTableName = "test_copy_job_destination_table_label"; Map labels = ImmutableMap.of("test_job_name", "test_copy_job"); @@ -3895,12 +3905,17 @@ public void testCopyJobWithLabels() throws InterruptedException { assertNotNull(createdTable); TableId destinationTable = TableId.of(DATASET, destinationTableName); CopyJobConfiguration configuration = - CopyJobConfiguration.newBuilder(destinationTable, sourceTable).setLabels(labels).build(); + CopyJobConfiguration.newBuilder(destinationTable, sourceTable) + .setLabels(labels) + .setDestinationExpirationTime(destExpiryTime) + .build(); Job remoteJob = bigquery.create(JobInfo.of(configuration)); remoteJob = remoteJob.waitFor(); assertNull(remoteJob.getStatus().getError()); CopyJobConfiguration copyJobConfiguration = remoteJob.getConfiguration(); assertEquals(labels, copyJobConfiguration.getLabels()); + assertNotNull(copyJobConfiguration.getDestinationExpirationTime()); + assertEquals(destExpiryTime, copyJobConfiguration.getDestinationExpirationTime()); Table remoteTable = bigquery.getTable(DATASET, destinationTableName); assertNotNull(remoteTable); assertTrue(createdTable.delete()); diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java index deabba59f..73bd21a30 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java @@ -341,6 +341,7 @@ public void testIterateAndOrderDefaultConnSettings() throws SQLException { @Test public void testConnectionClose() throws SQLException { Connection connection = bigquery.createConnection(); + assertNotNull("bigquery.createConnection() returned null", connection); BigQueryResult bigQueryResult = connection.executeSelect(QUERY); logger.log(Level.INFO, "Query used: {0}", QUERY); ResultSet rs = bigQueryResult.getResultSet(); diff --git a/pom.xml b/pom.xml index 05a6ce473..7a1b27941 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-bigquery-parent pom - 2.12.0 + 2.13.0 BigQuery Parent https://github.com/googleapis/java-bigquery @@ -96,7 +96,7 @@ com.google.cloud google-cloud-datacatalog-bom - 1.6.1 + 1.8.1 pom import @@ -104,7 +104,7 @@ com.google.cloud google-cloud-datacatalog-bom - 1.7.3 + 1.8.1 pom import @@ -118,7 +118,7 @@ com.google.cloud google-cloud-bigquery - 2.12.0 + 2.13.0 @@ -170,20 +170,20 @@ org.mockito mockito-core - 4.5.1 + 4.6.0 test com.google.cloud google-cloud-storage - 2.7.1 + 2.7.2 test org.assertj assertj-core - 3.22.0 + 2.9.1 test @@ -293,3 +293,4 @@ + diff --git a/renovate.json b/renovate.json index 2b19d40fd..56fe3f2ab 100644 --- a/renovate.json +++ b/renovate.json @@ -39,6 +39,7 @@ { "packagePatterns": [ "^com.google.cloud:google-cloud-bigquery", + "^com.google.cloud:google-cloud-bigtable", "^com.google.cloud:libraries-bom", "^com.google.cloud.samples:shared-configuration" ], @@ -70,11 +71,11 @@ { "packagePatterns": [ "^com.google.api.grpc:proto-google-cloud-datacatalog", - "^com.google.cloud:google-cloud-datacatalog" + "^com.google.cloud:google-cloud-datacatalog", + "^com.google.cloud:google-cloud-bigquerystorage-bom", + "^com.google.cloud:google-cloud-storage" ], - "groupName": "datacatalog dependencies", - "semanticCommitType": "test", - "semanticCommitScope": "deps" + "groupName": "cloud client dependencies" } ], "semanticCommits": true, diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 55cedc650..2f6508846 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.11.2 + 2.12.0 @@ -63,7 +63,7 @@ com.google.cloud google-cloud-bigtable - 2.7.0 + 2.8.0 test diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index a6c2f4398..6b9ccabbb 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigquery - 2.12.0 + 2.13.0 @@ -61,7 +61,7 @@ com.google.cloud google-cloud-bigtable - 2.7.0 + 2.8.0 test diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 821f95718..cda562651 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -79,7 +79,7 @@ com.google.cloud google-cloud-bigtable - 2.7.0 + 2.8.0 test diff --git a/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java b/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java index dc9a6a24f..86915bab7 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java +++ b/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java @@ -62,19 +62,11 @@ public static void queryPagination(String datasetName, String tableName, String .getValues() .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); - if (results.hasNextPage()) { - // Next Page - results - .getNextPage() - .getValues() - .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); - } - - if (results.hasNextPage()) { + while (results.hasNextPage()) { // Remaining Pages + results = results.getNextPage(); results - .getNextPage() - .iterateAll() + .getValues() .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); } diff --git a/versions.txt b/versions.txt index 026fbb39e..fca5ef218 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-bigquery:2.12.0:2.12.0 \ No newline at end of file +google-cloud-bigquery:2.13.0:2.13.0 \ No newline at end of file