Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ public Table apply(TableList.Tables tablePb) {
.setId(tablePb.getId())
.setKind(tablePb.getKind())
.setTableReference(tablePb.getTableReference())
.setType(tablePb.getType());
.setType(tablePb.getType())
.setCreationTime(tablePb.getCreationTime())
.setTimePartitioning(tablePb.getTimePartitioning());
}
}));
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,25 @@ public class BigQueryImplTest {
StandardTableDefinition.of(TABLE_SCHEMA);
private static final ModelTableDefinition MODEL_TABLE_DEFINITION =
ModelTableDefinition.newBuilder().build();
private static final Long EXPIRATION_MS = 86400000L;
private static final Long TABLE_CREATION_TIME = 1546275600000L;
private static final TimePartitioning TIME_PARTITIONING =
TimePartitioning.of(TimePartitioning.Type.DAY, EXPIRATION_MS);
private static final StandardTableDefinition TABLE_DEFINITION_WITH_PARTITIONING =
StandardTableDefinition.newBuilder()
.setSchema(TABLE_SCHEMA)
.setTimePartitioning(TIME_PARTITIONING)
.build();
private static final TableInfo TABLE_INFO = TableInfo.of(TABLE_ID, TABLE_DEFINITION);
private static final TableInfo OTHER_TABLE_INFO = TableInfo.of(OTHER_TABLE_ID, TABLE_DEFINITION);
private static final TableInfo TABLE_INFO_WITH_PROJECT =
TableInfo.of(TABLE_ID_WITH_PROJECT, TABLE_DEFINITION);
private static final TableInfo MODEL_TABLE_INFO_WITH_PROJECT =
TableInfo.of(TABLE_ID_WITH_PROJECT, MODEL_TABLE_DEFINITION);
private static final TableInfo TABLE_INFO_WITH_PARTITIONS =
TableInfo.newBuilder(TABLE_ID, TABLE_DEFINITION_WITH_PARTITIONING)
.setCreationTime(TABLE_CREATION_TIME)
.build();
private static final LoadJobConfiguration LOAD_JOB_CONFIGURATION =
LoadJobConfiguration.of(TABLE_ID, "URI");
private static final LoadJobConfiguration LOAD_JOB_CONFIGURATION_WITH_PROJECT =
Expand Down Expand Up @@ -714,6 +727,22 @@ public void testListTablesWithOptions() {
assertArrayEquals(tableList.toArray(), Iterables.toArray(page.getValues(), Table.class));
}

@Test
public void testListTablesReturnedParameters() {
bigquery = options.getService();
ImmutableList<Table> tableList =
ImmutableList.of(
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PARTITIONS)));
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
Tuple.of(CURSOR, Iterables.transform(tableList, TableInfo.TO_PB_FUNCTION));
EasyMock.expect(bigqueryRpcMock.listTables(PROJECT, DATASET, TABLE_LIST_OPTIONS))
.andReturn(result);
EasyMock.replay(bigqueryRpcMock);
Page<Table> page = bigquery.listTables(DATASET, TABLE_LIST_PAGE_SIZE, TABLE_LIST_PAGE_TOKEN);
assertEquals(CURSOR, page.getNextPageToken());
assertArrayEquals(tableList.toArray(), Iterables.toArray(page.getValues(), Table.class));
}

@Test
public void testDeleteTable() {
EasyMock.expect(bigqueryRpcMock.deleteTable(PROJECT, DATASET, TABLE)).andReturn(true);
Expand Down