Skip to content

Commit 7274e30

Browse files
Praful Makanisduskis
authored andcommitted
---
yaml --- r: 21119 b: refs/heads/autosynth-dlp c: f1d2976 h: refs/heads/master i: 21117: f94b5c9 21115: 83808c5 21111: 41b9e65 21103: c5e604e 21087: e0d6424 21055: c0cfae2 20991: 61fb378
1 parent 45d79dd commit 7274e30

4 files changed

Lines changed: 67 additions & 2 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ refs/tags/v0.60.0: 4cd518d0612329f8a8e53484eef4cd1651e32855
103103
refs/tags/v0.61.0: e4b526656bb1bf5eefd0ee578b7405147821225e
104104
refs/tags/v0.62.0: bbede7385d48ba08f487bdd29ec10668ace96396
105105
refs/heads/0.60.0-alpha: 10939381ffe0b8da32db4fe3087c86e3aa7f3e55
106-
refs/heads/autosynth-dlp: 8379b2c1be657233f817c25e0d3dfc99abf5a550
106+
refs/heads/autosynth-dlp: f1d2976e9fb26c440b94b9dfa012e52493132f53
107107
refs/heads/autosynth-logging: ffd2c58e5ab2ff0eb1410bbab4b81682a85a84d2
108108
refs/heads/dupes: 3478c5d81fd242d0e985656645a679420a2060c2
109109
refs/tags/v0.63.0: 94f19b71d40f46b36120e7b9d78a1a3d41bfcbd6

branches/autosynth-dlp/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ public Table apply(TableList.Tables tablePb) {
276276
.setId(tablePb.getId())
277277
.setKind(tablePb.getKind())
278278
.setTableReference(tablePb.getTableReference())
279-
.setType(tablePb.getType());
279+
.setType(tablePb.getType())
280+
.setCreationTime(tablePb.getCreationTime())
281+
.setTimePartitioning(tablePb.getTimePartitioning());
280282
}
281283
}));
282284
} catch (IOException ex) {

branches/autosynth-dlp/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,25 @@ public class BigQueryImplTest {
111111
StandardTableDefinition.of(TABLE_SCHEMA);
112112
private static final ModelTableDefinition MODEL_TABLE_DEFINITION =
113113
ModelTableDefinition.newBuilder().build();
114+
private static final Long EXPIRATION_MS = 86400000L;
115+
private static final Long TABLE_CREATION_TIME = 1546275600000L;
116+
private static final TimePartitioning TIME_PARTITIONING =
117+
TimePartitioning.of(TimePartitioning.Type.DAY, EXPIRATION_MS);
118+
private static final StandardTableDefinition TABLE_DEFINITION_WITH_PARTITIONING =
119+
StandardTableDefinition.newBuilder()
120+
.setSchema(TABLE_SCHEMA)
121+
.setTimePartitioning(TIME_PARTITIONING)
122+
.build();
114123
private static final TableInfo TABLE_INFO = TableInfo.of(TABLE_ID, TABLE_DEFINITION);
115124
private static final TableInfo OTHER_TABLE_INFO = TableInfo.of(OTHER_TABLE_ID, TABLE_DEFINITION);
116125
private static final TableInfo TABLE_INFO_WITH_PROJECT =
117126
TableInfo.of(TABLE_ID_WITH_PROJECT, TABLE_DEFINITION);
118127
private static final TableInfo MODEL_TABLE_INFO_WITH_PROJECT =
119128
TableInfo.of(TABLE_ID_WITH_PROJECT, MODEL_TABLE_DEFINITION);
129+
private static final TableInfo TABLE_INFO_WITH_PARTITIONS =
130+
TableInfo.newBuilder(TABLE_ID, TABLE_DEFINITION_WITH_PARTITIONING)
131+
.setCreationTime(TABLE_CREATION_TIME)
132+
.build();
120133
private static final LoadJobConfiguration LOAD_JOB_CONFIGURATION =
121134
LoadJobConfiguration.of(TABLE_ID, "URI");
122135
private static final LoadJobConfiguration LOAD_JOB_CONFIGURATION_WITH_PROJECT =
@@ -721,6 +734,22 @@ public void testListTables() {
721734
assertArrayEquals(tableList.toArray(), Iterables.toArray(page.getValues(), Table.class));
722735
}
723736

737+
@Test
738+
public void testListTablesReturnedParameters() {
739+
bigquery = options.getService();
740+
ImmutableList<Table> tableList =
741+
ImmutableList.of(
742+
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PARTITIONS)));
743+
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
744+
Tuple.of(CURSOR, Iterables.transform(tableList, TableInfo.TO_PB_FUNCTION));
745+
EasyMock.expect(bigqueryRpcMock.listTables(PROJECT, DATASET, TABLE_LIST_OPTIONS))
746+
.andReturn(result);
747+
EasyMock.replay(bigqueryRpcMock);
748+
Page<Table> page = bigquery.listTables(DATASET, TABLE_LIST_PAGE_SIZE, TABLE_LIST_PAGE_TOKEN);
749+
assertEquals(CURSOR, page.getNextPageToken());
750+
assertArrayEquals(tableList.toArray(), Iterables.toArray(page.getValues(), Table.class));
751+
}
752+
724753
@Test
725754
public void testListTablesFromDatasetId() {
726755
bigquery = options.getService();

branches/autosynth-dlp/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public class ITBigQueryTest {
111111

112112
private static final byte[] BYTES = {0xD, 0xE, 0xA, 0xD};
113113
private static final String BYTES_BASE64 = BaseEncoding.base64().encode(BYTES);
114+
private static final Long EXPIRATION_MS = 86400000L;
114115
private static final Logger LOG = Logger.getLogger(ITBigQueryTest.class.getName());
115116
private static final String DATASET = RemoteBigQueryHelper.generateDatasetName();
116117
private static final String DESCRIPTION = "Test dataset";
@@ -607,6 +608,39 @@ public void testListTables() {
607608
assertTrue(createdTable.delete());
608609
}
609610

611+
@Test
612+
public void testListTablesWithPartitioning() {
613+
String tableName = "test_list_tables_partitioning";
614+
TimePartitioning timePartitioning = TimePartitioning.of(Type.DAY, EXPIRATION_MS);
615+
StandardTableDefinition tableDefinition =
616+
StandardTableDefinition.newBuilder()
617+
.setSchema(TABLE_SCHEMA)
618+
.setTimePartitioning(timePartitioning)
619+
.build();
620+
TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
621+
Table createdPartitioningTable = bigquery.create(tableInfo);
622+
assertNotNull(createdPartitioningTable);
623+
try {
624+
Page<Table> tables = bigquery.listTables(DATASET);
625+
boolean found = false;
626+
Iterator<Table> tableIterator = tables.getValues().iterator();
627+
while (tableIterator.hasNext() && !found) {
628+
StandardTableDefinition standardTableDefinition = tableIterator.next().getDefinition();
629+
if (standardTableDefinition.getTimePartitioning() != null
630+
&& standardTableDefinition.getTimePartitioning().getType().equals(Type.DAY)
631+
&& standardTableDefinition
632+
.getTimePartitioning()
633+
.getExpirationMs()
634+
.equals(EXPIRATION_MS)) {
635+
found = true;
636+
}
637+
}
638+
assertTrue(found);
639+
} finally {
640+
createdPartitioningTable.delete();
641+
}
642+
}
643+
610644
@Test
611645
public void testUpdateTable() {
612646
String tableName = "test_update_table";

0 commit comments

Comments
 (0)