diff --git a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java b/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java index 5c5dcd496d61..090d6c87ca45 100644 --- a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java +++ b/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java @@ -89,6 +89,7 @@ enum TableField implements FieldSelector { EXTERNAL_DATA_CONFIGURATION("externalDataConfiguration"), FRIENDLY_NAME("friendlyName"), ID("id"), + LABELS("labels"), LAST_MODIFIED_TIME("lastModifiedTime"), LOCATION("location"), NUM_BYTES("numBytes"), diff --git a/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index 3a07a4166ef7..f1b1c8c67f19 100644 --- a/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -420,16 +420,19 @@ public void testCreateAndGetTableWithSelectedField() { String tableName = "test_create_and_get_selected_fields_table"; TableId tableId = TableId.of(DATASET, tableName); StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA); - Table createdTable = bigquery.create(TableInfo.of(tableId, tableDefinition)); + Table createdTable = bigquery.create(TableInfo.newBuilder(tableId, tableDefinition) + .setLabels(Collections.singletonMap("a", "b")) + .build()); assertNotNull(createdTable); assertEquals(DATASET, createdTable.getTableId().getDataset()); assertEquals(tableName, createdTable.getTableId().getTable()); Table remoteTable = bigquery.getTable(DATASET, tableName, - TableOption.fields(TableField.CREATION_TIME)); + TableOption.fields(TableField.CREATION_TIME, TableField.LABELS)); assertNotNull(remoteTable); assertTrue(remoteTable.getDefinition() instanceof StandardTableDefinition); assertEquals(createdTable.getTableId(), remoteTable.getTableId()); assertEquals(TableDefinition.Type.TABLE, remoteTable.getDefinition().getType()); + assertThat(remoteTable.getLabels()).containsExactly("a", "b"); assertNotNull(remoteTable.getCreationTime()); assertNull(remoteTable.getDefinition().getSchema()); assertNull(remoteTable.getLastModifiedTime());