Skip to content

Commit

Permalink
BigQuery: Add support for retreiving labels (#3879)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseLovelace committed Oct 30, 2018
1 parent 19fe6eb commit f69e7fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit f69e7fa

Please sign in to comment.