Skip to content

Commit 1005057

Browse files
shollymansduskis
authored andcommitted
---
yaml --- r: 16127 b: refs/heads/autosynth-errorreporting c: 7ee8aa1 h: refs/heads/master i: 16125: d16f6f9 16123: c651772 16119: 0120c93 16111: 8187162 16095: 62a2320 16063: 72eed0b 15999: bd14052 15871: d3afc32
1 parent 8301d89 commit 1005057

6 files changed

Lines changed: 45 additions & 8 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca
131131
refs/heads/autosynth-containeranalysis: 039ca5b8db725c76c16a965ff26b2774322b8ef8
132132
refs/heads/autosynth-datastore: 9acd400b484d6691a080c9152a331d88d24fefc1
133133
refs/heads/autosynth-dialogflow: d7477419376eac9b6dcc7dbcede581152527351d
134-
refs/heads/autosynth-errorreporting: afdc7eab2bb157d3a82f03243a84d5893e618491
134+
refs/heads/autosynth-errorreporting: 7ee8aa1913cf6dbed7c704deb118c9d3ec5e4cfe
135135
refs/heads/autosynth-firestore: 92b27fbc8855c9902168695abb0a8f1f433b750b
136136
refs/heads/autosynth-iot: 9d732be07d99843d8cb53d34ec0837328a807fce
137137
refs/heads/autosynth-kms: dcc6e15d68759010c8735cc868135bd7e6c1cc5f

branches/autosynth-errorreporting/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/FieldValue.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public enum Attribute {
4848
* type {@link LegacySQLTypeName#BYTES}, {@link LegacySQLTypeName#BOOLEAN}, {@link
4949
* LegacySQLTypeName#STRING}, {@link LegacySQLTypeName#FLOAT}, {@link
5050
* LegacySQLTypeName#INTEGER}, {@link LegacySQLTypeName#NUMERIC}, {@link
51-
* LegacySQLTypeName#TIMESTAMP}, or the value is set to {@code null}.
51+
* LegacySQLTypeName#TIMESTAMP}, {@link LegacySQLTypeName#GEOGRAPHY} or the value is set to
52+
* {@code null}.
5253
*/
5354
PRIMITIVE,
5455

@@ -71,9 +72,10 @@ private FieldValue(Attribute attribute, Object value) {
7172
* LegacySQLTypeName#BYTES}, {@link LegacySQLTypeName#BOOLEAN}, {@link
7273
* LegacySQLTypeName#STRING}, {@link LegacySQLTypeName#FLOAT}, {@link
7374
* LegacySQLTypeName#INTEGER}, {@link LegacySQLTypeName#NUMERIC}, {@link
74-
* LegacySQLTypeName#TIMESTAMP}) or is {@code null}. Returns {@link Attribute#REPEATED} if the
75-
* corresponding field has ({@link Field.Mode#REPEATED}) mode. Returns {@link
76-
* Attribute#RECORD} if the corresponding field is a {@link LegacySQLTypeName#RECORD} type.
75+
* LegacySQLTypeName#TIMESTAMP}, {@link LegacySQLTypeName#GEOGRAPHY}) or is {@code null}.
76+
* <p>Returns {@link Attribute#REPEATED} if the corresponding field has ({@link
77+
* Field.Mode#REPEATED}) mode. Returns {@link Attribute#RECORD} if the corresponding field is
78+
* a {@link LegacySQLTypeName#RECORD} type.
7779
*/
7880
public Attribute getAttribute() {
7981
return attribute;

branches/autosynth-errorreporting/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LegacySQLTypeName.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public LegacySQLTypeName apply(String constant) {
7070
/** Represents a logical calendar date. Note, support for this type is limited in legacy SQL. */
7171
public static final LegacySQLTypeName DATE =
7272
type.createAndRegister("DATE").setStandardType(StandardSQLTypeName.DATE);
73+
/** Represents a set of geographic points, represented as a Well Known Text (WKT) string. */
74+
public static final LegacySQLTypeName GEOGRAPHY =
75+
type.createAndRegister("GEOGRAPHY").setStandardType(StandardSQLTypeName.GEOGRAPHY);
7376
/**
7477
* Represents a time, independent of a specific date, to microsecond precision. Note, support for
7578
* this type is limited in legacy SQL.

branches/autosynth-errorreporting/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/StandardSQLTypeName.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ public enum StandardSQLTypeName {
5050
/** Represents a time, independent of a specific date, to microsecond precision. */
5151
TIME,
5252
/** Represents a year, month, day, hour, minute, second, and subsecond (microsecond precision). */
53-
DATETIME
53+
DATETIME,
54+
/** Represents a set of geographic points, represented as a Well Known Text (WKT) string. */
55+
GEOGRAPHY
5456
}

branches/autosynth-errorreporting/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class FieldValueTest {
3737
private static final TableCell BOOLEAN_FIELD = new TableCell().setV("false");
3838
private static final Map<String, String> INTEGER_FIELD = ImmutableMap.of("v", "1");
3939
private static final Map<String, String> FLOAT_FIELD = ImmutableMap.of("v", "1.5");
40+
private static final Map<String, String> GEOGRAPHY_FIELD =
41+
ImmutableMap.of("v", "POINT(-122.350220 47.649154)");
4042
private static final Map<String, String> NUMERIC_FIELD =
4143
ImmutableMap.of("v", "123456789.123456789");
4244
private static final Map<String, String> STRING_FIELD = ImmutableMap.of("v", "string");
@@ -60,6 +62,9 @@ public void testFromPb() {
6062
value = FieldValue.fromPb(FLOAT_FIELD);
6163
assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
6264
assertEquals(1.5, value.getDoubleValue(), 0);
65+
value = FieldValue.fromPb(GEOGRAPHY_FIELD);
66+
assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
67+
assertEquals("POINT(-122.350220 47.649154)", value.getStringValue());
6368
value = FieldValue.fromPb(NUMERIC_FIELD);
6469
assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
6570
assertEquals(new BigDecimal("123456789.123456789"), value.getNumericValue());
@@ -98,6 +103,11 @@ public void testEquals() {
98103
assertEquals(floatValue, FieldValue.fromPb(FLOAT_FIELD));
99104
assertEquals(floatValue.hashCode(), FieldValue.fromPb(FLOAT_FIELD).hashCode());
100105

106+
FieldValue geographyValue =
107+
FieldValue.of(FieldValue.Attribute.PRIMITIVE, "POINT(-122.350220 47.649154)");
108+
assertEquals(geographyValue, FieldValue.fromPb(GEOGRAPHY_FIELD));
109+
assertEquals(geographyValue.hashCode(), FieldValue.fromPb(GEOGRAPHY_FIELD).hashCode());
110+
101111
FieldValue numericValue = FieldValue.of(FieldValue.Attribute.PRIMITIVE, "123456789.123456789");
102112
assertEquals(numericValue, FieldValue.fromPb(NUMERIC_FIELD));
103113
assertEquals(numericValue.hashCode(), FieldValue.fromPb(NUMERIC_FIELD).hashCode());

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)