@@ -166,6 +166,11 @@ public class ITBigQueryTest {
166166 .setMode (Field .Mode .NULLABLE )
167167 .setDescription ("FloatDescription" )
168168 .build ();
169+ private static final Field GEOGRAPHY_FIELD_SCHEMA =
170+ Field .newBuilder ("GeographyField" , LegacySQLTypeName .GEOGRAPHY )
171+ .setMode (Field .Mode .NULLABLE )
172+ .setDescription ("GeographyDescription" )
173+ .build ();
169174 private static final Field NUMERIC_FIELD_SCHEMA =
170175 Field .newBuilder ("NumericField" , LegacySQLTypeName .NUMERIC )
171176 .setMode (Field .Mode .NULLABLE )
@@ -181,6 +186,7 @@ public class ITBigQueryTest {
181186 RECORD_FIELD_SCHEMA ,
182187 INTEGER_FIELD_SCHEMA ,
183188 FLOAT_FIELD_SCHEMA ,
189+ GEOGRAPHY_FIELD_SCHEMA ,
184190 NUMERIC_FIELD_SCHEMA );
185191 private static final Schema SIMPLE_SCHEMA = Schema .of (STRING_FIELD_SCHEMA );
186192 private static final Schema QUERY_RESULT_SCHEMA =
@@ -220,6 +226,7 @@ public class ITBigQueryTest {
220226 + " },"
221227 + " \" IntegerField\" : \" 3\" ,"
222228 + " \" FloatField\" : \" 1.2\" ,"
229+ + " \" GeographyField\" : \" POINT(-122.35022 47.649154)\" ,"
223230 + " \" NumericField\" : \" 123456.789012345\" "
224231 + "}\n "
225232 + "{"
@@ -241,6 +248,7 @@ public class ITBigQueryTest {
241248 + " },"
242249 + " \" IntegerField\" : \" 3\" ,"
243250 + " \" FloatField\" : \" 1.2\" ,"
251+ + " \" GeographyField\" : \" POINT(-122.35022 47.649154)\" ,"
244252 + " \" NumericField\" : \" 123456.789012345\" "
245253 + "}" ;
246254
@@ -750,6 +758,7 @@ public void testInsertAll() throws IOException {
750758 BYTES_BASE64 ));
751759 builder1 .put ("IntegerField" , 5 );
752760 builder1 .put ("FloatField" , 1.2 );
761+ builder1 .put ("GeographyField" , "POINT(-122.350220 47.649154)" );
753762 builder1 .put ("NumericField" , new BigDecimal ("123456789.123456789" ));
754763 ImmutableMap .Builder <String , Object > builder2 = ImmutableMap .builder ();
755764 builder2 .put ("TimestampField" , "2014-08-19 07:41:35.220 -05:00" );
@@ -770,6 +779,7 @@ public void testInsertAll() throws IOException {
770779 BYTES_BASE64 ));
771780 builder2 .put ("IntegerField" , 5 );
772781 builder2 .put ("FloatField" , 1.2 );
782+ builder2 .put ("GeographyField" , "POINT(-122.350220 47.649154)" );
773783 builder2 .put ("NumericField" , new BigDecimal ("123456789.123456789" ));
774784 InsertAllRequest request =
775785 InsertAllRequest .newBuilder (tableInfo .getTableId ())
@@ -807,6 +817,7 @@ public void testInsertAllWithSuffix() throws InterruptedException {
807817 BYTES_BASE64 ));
808818 builder1 .put ("IntegerField" , 5 );
809819 builder1 .put ("FloatField" , 1.2 );
820+ builder1 .put ("GeographyField" , "POINT(-122.350220 47.649154)" );
810821 builder1 .put ("NumericField" , new BigDecimal ("123456789.123456789" ));
811822 ImmutableMap .Builder <String , Object > builder2 = ImmutableMap .builder ();
812823 builder2 .put ("TimestampField" , "2014-08-19 07:41:35.220 -05:00" );
@@ -827,6 +838,7 @@ public void testInsertAllWithSuffix() throws InterruptedException {
827838 BYTES_BASE64 ));
828839 builder2 .put ("IntegerField" , 5 );
829840 builder2 .put ("FloatField" , 1.2 );
841+ builder2 .put ("GeographyField" , "POINT(-122.350220 47.649154)" );
830842 builder2 .put ("NumericField" , new BigDecimal ("123456789.123456789" ));
831843 InsertAllRequest request =
832844 InsertAllRequest .newBuilder (tableInfo .getTableId ())
@@ -873,6 +885,7 @@ public void testInsertAllWithErrors() {
873885 BYTES_BASE64 ));
874886 builder1 .put ("IntegerField" , 5 );
875887 builder1 .put ("FloatField" , 1.2 );
888+ builder1 .put ("GeographyField" , "POINT(-122.350220 47.649154)" );
876889 builder1 .put ("NumericField" , new BigDecimal ("123456789.123456789" ));
877890 ImmutableMap .Builder <String , Object > builder2 = ImmutableMap .builder ();
878891 builder2 .put ("TimestampField" , "invalidDate" );
@@ -893,6 +906,7 @@ public void testInsertAllWithErrors() {
893906 BYTES_BASE64 ));
894907 builder2 .put ("IntegerField" , 5 );
895908 builder2 .put ("FloatField" , 1.2 );
909+ builder2 .put ("GeographyField" , "POINT(-122.350220 47.649154)" );
896910 builder2 .put ("NumericField" , new BigDecimal ("123456789.123456789" ));
897911 ImmutableMap .Builder <String , Object > builder3 = ImmutableMap .builder ();
898912 builder3 .put ("TimestampField" , "2014-08-19 07:41:35.220 -05:00" );
@@ -928,7 +942,8 @@ public void testListAllTableData() {
928942 FieldValue recordCell = row .get (5 );
929943 FieldValue integerCell = row .get (6 );
930944 FieldValue floatCell = row .get (7 );
931- FieldValue numericCell = row .get (8 );
945+ FieldValue geographyCell = row .get (8 );
946+ FieldValue numericCell = row .get (9 );
932947 assertEquals (FieldValue .Attribute .PRIMITIVE , timestampCell .getAttribute ());
933948 assertEquals (FieldValue .Attribute .PRIMITIVE , stringCell .getAttribute ());
934949 assertEquals (FieldValue .Attribute .REPEATED , integerArrayCell .getAttribute ());
@@ -937,6 +952,7 @@ public void testListAllTableData() {
937952 assertEquals (FieldValue .Attribute .RECORD , recordCell .getAttribute ());
938953 assertEquals (FieldValue .Attribute .PRIMITIVE , integerCell .getAttribute ());
939954 assertEquals (FieldValue .Attribute .PRIMITIVE , floatCell .getAttribute ());
955+ assertEquals (FieldValue .Attribute .PRIMITIVE , geographyCell .getAttribute ());
940956 assertEquals (FieldValue .Attribute .PRIMITIVE , numericCell .getAttribute ());
941957 assertEquals (1408452095220000L , timestampCell .getTimestampValue ());
942958 assertEquals ("stringValue" , stringCell .getStringValue ());
@@ -951,6 +967,7 @@ public void testListAllTableData() {
951967 assertEquals (true , recordCell .getRecordValue ().get (3 ).getBooleanValue ());
952968 assertEquals (3 , integerCell .getLongValue ());
953969 assertEquals (1.2 , floatCell .getDoubleValue (), 0.0001 );
970+ assertEquals ("POINT(-122.35022 47.649154)" , geographyCell .getStringValue ());
954971 assertEquals (new BigDecimal ("123456.789012345" ), numericCell .getNumericValue ());
955972 rowCount ++;
956973 }
@@ -1350,7 +1367,8 @@ public void testInsertFromFile() throws InterruptedException, IOException, Timeo
13501367 FieldValue recordCell = row .get (5 );
13511368 FieldValue integerCell = row .get (6 );
13521369 FieldValue floatCell = row .get (7 );
1353- FieldValue numericCell = row .get (8 );
1370+ FieldValue geographyCell = row .get (8 );
1371+ FieldValue numericCell = row .get (9 );
13541372 assertEquals (FieldValue .Attribute .PRIMITIVE , timestampCell .getAttribute ());
13551373 assertEquals (FieldValue .Attribute .PRIMITIVE , stringCell .getAttribute ());
13561374 assertEquals (FieldValue .Attribute .REPEATED , integerArrayCell .getAttribute ());
@@ -1359,6 +1377,7 @@ public void testInsertFromFile() throws InterruptedException, IOException, Timeo
13591377 assertEquals (FieldValue .Attribute .RECORD , recordCell .getAttribute ());
13601378 assertEquals (FieldValue .Attribute .PRIMITIVE , integerCell .getAttribute ());
13611379 assertEquals (FieldValue .Attribute .PRIMITIVE , floatCell .getAttribute ());
1380+ assertEquals (FieldValue .Attribute .PRIMITIVE , geographyCell .getAttribute ());
13621381 assertEquals (FieldValue .Attribute .PRIMITIVE , numericCell .getAttribute ());
13631382 assertEquals (1408452095220000L , timestampCell .getTimestampValue ());
13641383 assertEquals ("stringValue" , stringCell .getStringValue ());
@@ -1373,6 +1392,7 @@ public void testInsertFromFile() throws InterruptedException, IOException, Timeo
13731392 assertEquals (true , recordCell .getRecordValue ().get (3 ).getBooleanValue ());
13741393 assertEquals (3 , integerCell .getLongValue ());
13751394 assertEquals (1.2 , floatCell .getDoubleValue (), 0.0001 );
1395+ assertEquals ("POINT(-122.35022 47.649154)" , geographyCell .getStringValue ());
13761396 assertEquals (new BigDecimal ("123456.789012345" ), numericCell .getNumericValue ());
13771397 rowCount ++;
13781398 }
0 commit comments