@@ -116,11 +116,22 @@ public class BigQueryImplTest {
116
116
private static final Long TABLE_CREATION_TIME = 1546275600000L ;
117
117
private static final TimePartitioning TIME_PARTITIONING =
118
118
TimePartitioning .of (TimePartitioning .Type .DAY , EXPIRATION_MS );
119
+ private static final com .google .api .services .bigquery .model .TimePartitioning PB_TIMEPARTITIONING =
120
+ new com .google .api .services .bigquery .model .TimePartitioning ()
121
+ .setType (null )
122
+ .setField ("timestampField" );
123
+ private static final TimePartitioning TIME_PARTITIONING_NULL_TYPE =
124
+ TimePartitioning .fromPb (PB_TIMEPARTITIONING );
119
125
private static final StandardTableDefinition TABLE_DEFINITION_WITH_PARTITIONING =
120
126
StandardTableDefinition .newBuilder ()
121
127
.setSchema (TABLE_SCHEMA )
122
128
.setTimePartitioning (TIME_PARTITIONING )
123
129
.build ();
130
+ private static final StandardTableDefinition TABLE_DEFINITION_WITH_PARTITIONING_NULL_TYPE =
131
+ StandardTableDefinition .newBuilder ()
132
+ .setSchema (TABLE_SCHEMA )
133
+ .setTimePartitioning (TIME_PARTITIONING_NULL_TYPE )
134
+ .build ();
124
135
private static final RangePartitioning .Range RANGE =
125
136
RangePartitioning .Range .newBuilder ().setStart (1L ).setInterval (2L ).setEnd (10L ).build ();
126
137
private static final RangePartitioning RANGE_PARTITIONING =
@@ -142,7 +153,10 @@ public class BigQueryImplTest {
142
153
TableInfo .newBuilder (TABLE_ID , TABLE_DEFINITION_WITH_PARTITIONING )
143
154
.setCreationTime (TABLE_CREATION_TIME )
144
155
.build ();
145
-
156
+ private static final TableInfo TABLE_INFO_WITH_PARTITIONS_NULL_TYPE =
157
+ TableInfo .newBuilder (TABLE_ID , TABLE_DEFINITION_WITH_PARTITIONING_NULL_TYPE )
158
+ .setCreationTime (TABLE_CREATION_TIME )
159
+ .build ();
146
160
private static final ModelId OTHER_MODEL_ID = ModelId .of (DATASET , OTHER_MODEL );
147
161
private static final ModelId MODEL_ID_WITH_PROJECT = ModelId .of (PROJECT , DATASET , MODEL );
148
162
@@ -912,6 +926,22 @@ public void testListTablesReturnedParameters() {
912
926
assertArrayEquals (tableList .toArray (), Iterables .toArray (page .getValues (), Table .class ));
913
927
}
914
928
929
+ @ Test
930
+ public void testListTablesReturnedParametersNullType () {
931
+ bigquery = options .getService ();
932
+ ImmutableList <Table > tableList =
933
+ ImmutableList .of (
934
+ new Table (bigquery , new TableInfo .BuilderImpl (TABLE_INFO_WITH_PARTITIONS_NULL_TYPE )));
935
+ Tuple <String , Iterable <com .google .api .services .bigquery .model .Table >> result =
936
+ Tuple .of (CURSOR , Iterables .transform (tableList , TableInfo .TO_PB_FUNCTION ));
937
+ EasyMock .expect (bigqueryRpcMock .listTables (PROJECT , DATASET , TABLE_LIST_OPTIONS ))
938
+ .andReturn (result );
939
+ EasyMock .replay (bigqueryRpcMock );
940
+ Page <Table > page = bigquery .listTables (DATASET , TABLE_LIST_PAGE_SIZE , TABLE_LIST_PAGE_TOKEN );
941
+ assertEquals (CURSOR , page .getNextPageToken ());
942
+ assertArrayEquals (tableList .toArray (), Iterables .toArray (page .getValues (), Table .class ));
943
+ }
944
+
915
945
@ Test
916
946
public void testListTablesWithRangePartitioning () {
917
947
bigquery = options .getService ();
0 commit comments