1717package com .google .cloud .bigquery ;
1818
1919import static org .junit .jupiter .api .Assertions .assertEquals ;
20+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
2021import static org .junit .jupiter .api .Assertions .assertNull ;
2122import static org .junit .jupiter .api .Assertions .fail ;
2223
3738import org .apache .arrow .vector .VarBinaryVector ;
3839import org .apache .arrow .vector .VarCharVector ;
3940import org .apache .arrow .vector .VectorSchemaRoot ;
41+ import org .apache .arrow .vector .VectorUnloader ;
4042import org .apache .arrow .vector .ipc .WriteChannel ;
4143import org .apache .arrow .vector .ipc .message .ArrowRecordBatch ;
4244import org .apache .arrow .vector .ipc .message .MessageSerializer ;
4345import org .apache .arrow .vector .types .TimeUnit ;
4446import org .apache .arrow .vector .types .pojo .ArrowType ;
45- import org .apache .arrow .vector .types .pojo .Field ;
4647import org .apache .arrow .vector .types .pojo .FieldType ;
4748import org .junit .jupiter .api .Test ;
4849
4950public class ArrowDeserializerTest {
5051
5152 @ Test
5253 public void testArrowSchemaToBigQuerySchema () {
53- Field intField = new Field ("int_col" , FieldType .nullable (new ArrowType .Int (32 , true )), null );
54- Field strField = new Field ("str_col" , FieldType .notNullable (new ArrowType .Utf8 ()), null );
55- Field boolField = new Field ("bool_col" , FieldType .nullable (new ArrowType .Bool ()), null );
56- Field tsField =
57- new Field (
54+ org .apache .arrow .vector .types .pojo .Field intField =
55+ new org .apache .arrow .vector .types .pojo .Field (
56+ "int_col" , FieldType .nullable (new ArrowType .Int (32 , true )), null );
57+ org .apache .arrow .vector .types .pojo .Field strField =
58+ new org .apache .arrow .vector .types .pojo .Field (
59+ "str_col" , FieldType .notNullable (new ArrowType .Utf8 ()), null );
60+ org .apache .arrow .vector .types .pojo .Field boolField =
61+ new org .apache .arrow .vector .types .pojo .Field (
62+ "bool_col" , FieldType .nullable (new ArrowType .Bool ()), null );
63+ org .apache .arrow .vector .types .pojo .Field tsField =
64+ new org .apache .arrow .vector .types .pojo .Field (
5865 "ts_col" ,
5966 FieldType .nullable (new ArrowType .Timestamp (TimeUnit .MICROSECOND , "UTC" )),
6067 null );
@@ -68,13 +75,11 @@ public void testArrowSchemaToBigQuerySchema() {
6875 assertEquals (4 , bqSchema .getFields ().size ());
6976 assertEquals ("int_col" , bqSchema .getFields ().get (0 ).getName ());
7077 assertEquals (LegacySQLTypeName .INTEGER , bqSchema .getFields ().get (0 ).getType ());
71- assertEquals (
72- com .google .cloud .bigquery .Field .Mode .NULLABLE , bqSchema .getFields ().get (0 ).getMode ());
78+ assertEquals (Field .Mode .NULLABLE , bqSchema .getFields ().get (0 ).getMode ());
7379
7480 assertEquals ("str_col" , bqSchema .getFields ().get (1 ).getName ());
7581 assertEquals (LegacySQLTypeName .STRING , bqSchema .getFields ().get (1 ).getType ());
76- assertEquals (
77- com .google .cloud .bigquery .Field .Mode .REQUIRED , bqSchema .getFields ().get (1 ).getMode ());
82+ assertEquals (Field .Mode .REQUIRED , bqSchema .getFields ().get (1 ).getMode ());
7883
7984 assertEquals ("bool_col" , bqSchema .getFields ().get (2 ).getName ());
8085 assertEquals (LegacySQLTypeName .BOOLEAN , bqSchema .getFields ().get (2 ).getType ());
@@ -124,7 +129,8 @@ public void testDeserializeRecordBatchPrimitives() throws IOException {
124129 tsVector .setValueCount (2 );
125130
126131 List <FieldVector > vectors =
127- ImmutableList .of (intVector , nameVector , scoreVector , activeVector , bytesVector , tsVector );
132+ ImmutableList .of (
133+ intVector , nameVector , scoreVector , activeVector , bytesVector , tsVector );
128134
129135 try (VectorSchemaRoot root = new VectorSchemaRoot (vectors )) {
130136 org .apache .arrow .vector .types .pojo .Schema arrowSchema = root .getSchema ();
@@ -175,8 +181,8 @@ public void testSchemaMismatchThrowsException() {
175181 try (VectorSchemaRoot root = new VectorSchemaRoot (ImmutableList .of (intVector ))) {
176182 Schema mismatchedSchema =
177183 Schema .of (
178- com . google . cloud . bigquery . Field .of ("col1" , LegacySQLTypeName .INTEGER ),
179- com . google . cloud . bigquery . Field .of ("col2" , LegacySQLTypeName .STRING ));
184+ Field .of ("col1" , LegacySQLTypeName .INTEGER ),
185+ Field .of ("col2" , LegacySQLTypeName .STRING ));
180186
181187 try {
182188 ArrowDeserializer .arrowRootToFieldValueList (root , 0 , mismatchedSchema );
@@ -195,8 +201,7 @@ private byte[] serializeVectorSchemaRoot(VectorSchemaRoot root, BufferAllocator
195201 ByteArrayOutputStream out = new ByteArrayOutputStream ();
196202 WriteChannel channel = new WriteChannel (Channels .newChannel (out ));
197203
198- org .apache .arrow .vector .VectorUnloader unloader =
199- new org .apache .arrow .vector .VectorUnloader (root );
204+ VectorUnloader unloader = new VectorUnloader (root );
200205 try (ArrowRecordBatch batch = unloader .getRecordBatch ()) {
201206 MessageSerializer .serialize (channel , batch );
202207 }
0 commit comments