From 974cf2e6928e3d4d588cd9c6535280fc5c5a4090 Mon Sep 17 00:00:00 2001 From: stephwang Date: Fri, 12 Nov 2021 16:02:07 -0500 Subject: [PATCH 1/3] feat: set Table.Schema for permanent external tables --- .../google/cloud/bigquery/BigQueryImpl.java | 6 +++++ .../cloud/bigquery/it/ITBigQueryTest.java | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java index 7d0e4c5550..d2867b0b94 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java @@ -286,6 +286,12 @@ public Table create(TableInfo tableInfo, TableOption... options) { ? getOptions().getProjectId() : tableInfo.getTableId().getProject()) .toPb(); + // Set schema on the Table for permanent external table + if (tablePb.getExternalDataConfiguration() != null) { + tablePb.setSchema(tablePb.getExternalDataConfiguration().getSchema()); + // clear table schema on ExternalDataConfiguration + tablePb.getExternalDataConfiguration().setSchema(null); + } final Map optionsMap = optionMap(options); try { return Table.fromPb( 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 8460bccb78..48ccde887e 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 @@ -953,6 +953,28 @@ public void testCreateExternalTable() throws InterruptedException { assertTrue(remoteTable.delete()); } + @Test + public void testSetPermExternalTableSchema() { + String tableName = "test_create_external_table_perm"; + TableId tableId = TableId.of(DATASET, tableName); + ExternalTableDefinition externalTableDefinition = + ExternalTableDefinition.newBuilder( + "gs://" + BUCKET + "/" + JSON_LOAD_FILE, FormatOptions.json()) + .setSchema(TABLE_SCHEMA) + .setConnectionId( + // TODO: SET UP CONNECTION FOR THE TEST + "projects/java-docs-samples-testing/locations/us/connections/[TODO:CONNECTION]") + .build(); + TableInfo tableInfo = TableInfo.of(tableId, externalTableDefinition); + // Table createdTable = bigquery.create(tableInfo); + // + // assertNotNull(createdTable); + // assertEquals(DATASET, createdTable.getTableId().getDataset()); + // assertEquals(tableName, createdTable.getTableId().getTable()); + // Table remoteTable = bigquery.getTable(DATASET, tableName); + // assertNotNull(remoteTable); + } + @Test public void testCreateViewTable() throws InterruptedException { String tableName = "test_create_view_table"; From 1010f3a52b31621d1322a9b8ff1f74620806f50c Mon Sep 17 00:00:00 2001 From: stephwang Date: Wed, 24 Nov 2021 11:23:47 -0500 Subject: [PATCH 2/3] update with ConnectionId --- .../cloud/bigquery/it/ITBigQueryTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 48ccde887e..a382c91f25 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 @@ -962,17 +962,17 @@ public void testSetPermExternalTableSchema() { "gs://" + BUCKET + "/" + JSON_LOAD_FILE, FormatOptions.json()) .setSchema(TABLE_SCHEMA) .setConnectionId( - // TODO: SET UP CONNECTION FOR THE TEST - "projects/java-docs-samples-testing/locations/us/connections/[TODO:CONNECTION]") + "projects/java-docs-samples-testing/locations/us/connections/DEVREL_TEST_CONNECTION") .build(); TableInfo tableInfo = TableInfo.of(tableId, externalTableDefinition); - // Table createdTable = bigquery.create(tableInfo); - // - // assertNotNull(createdTable); - // assertEquals(DATASET, createdTable.getTableId().getDataset()); - // assertEquals(tableName, createdTable.getTableId().getTable()); - // Table remoteTable = bigquery.getTable(DATASET, tableName); - // assertNotNull(remoteTable); + Table createdTable = bigquery.create(tableInfo); + + assertNotNull(createdTable); + assertEquals(DATASET, createdTable.getTableId().getDataset()); + assertEquals(tableName, createdTable.getTableId().getTable()); + Table remoteTable = bigquery.getTable(DATASET, tableName); + assertNotNull(remoteTable); + assertTrue(remoteTable.delete()); } @Test From fe2347ee1afa9efc2af394ed07cfaee3ebd315bb Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 10 Mar 2022 15:56:37 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9f0ac2232a..3967fb13f2 100644 --- a/README.md +++ b/README.md @@ -51,20 +51,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.0.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.3.3' +implementation 'com.google.cloud:google-cloud-bigquery:2.9.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.3.3" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.9.4" ``` ## Authentication