Skip to content

Commit 59f1790

Browse files
authored
---
yaml --- r: 13851 b: refs/heads/autosynth-compute c: ea68410 h: refs/heads/master i: 13849: 1fddee2 13847: 6f51726
1 parent da20642 commit 59f1790

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

  • branches/autosynth-compute/google-cloud-clients/google-cloud-bigquery/src

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ refs/tags/v0.64.0: 456e8fbd129deced3ca025f239a2d8a82bde1d0a
112112
refs/tags/v0.65.0: 10939381ffe0b8da32db4fe3087c86e3aa7f3e55
113113
refs/tags/v0.66.0: ed6a3f57cbdaa20339a1995f7d7d53b172a5b8ef
114114
refs/tags/v0.67.0: 30b56f02092efc6f3c3667650ea8b8825003e0b7
115-
refs/heads/autosynth-compute: 2aa9d803ed532d91a5f430368f1ec4fd21f3dd24
115+
refs/heads/autosynth-compute: ea68410f175b64ab06ff8bd1371935d12e3ce3e9
116116
refs/heads/autosynth-container: d0346e84b1f26e3dc10444450a998f357a43bcef
117117
refs/heads/autosynth-dataproc: bc74a8841bc1693d7945d991d15979df550b1fd1
118118
refs/heads/autosynth-monitoring: 120f508e0065f4ce39cf0e6a69a08138773f2cfb

branches/autosynth-compute/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Schema.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21+
import com.google.api.services.bigquery.model.TableFieldSchema;
2122
import com.google.api.services.bigquery.model.TableSchema;
2223
import com.google.common.base.Function;
2324
import com.google.common.base.MoreObjects;
2425
import java.io.Serializable;
26+
import java.util.Collections;
27+
import java.util.List;
2528
import java.util.Objects;
2629

2730
/** This class represents the schema for a Google BigQuery Table or data source. */
@@ -90,6 +93,10 @@ TableSchema toPb() {
9093
}
9194

9295
static Schema fromPb(com.google.api.services.bigquery.model.TableSchema tableSchemaPb) {
93-
return Schema.of(FieldList.fromPb(tableSchemaPb.getFields()));
96+
List<TableFieldSchema> fields = tableSchemaPb.getFields();
97+
if (fields == null) {
98+
fields = Collections.emptyList();
99+
}
100+
return Schema.of(FieldList.fromPb(fields));
94101
}
95102
}

branches/autosynth-compute/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020

21+
import com.google.api.services.bigquery.model.TableSchema;
2122
import com.google.common.collect.ImmutableList;
2223
import java.util.List;
2324
import org.junit.Test;
@@ -57,4 +58,11 @@ private void compareTableSchema(Schema expected, Schema value) {
5758
assertEquals(expected, value);
5859
assertEquals(expected.getFields(), value.getFields());
5960
}
61+
62+
@Test
63+
public void testEmptySchema() {
64+
TableSchema tableSchema = new TableSchema();
65+
Schema schema = Schema.fromPb(tableSchema);
66+
assertEquals(0, schema.getFields().size());
67+
}
6068
}

0 commit comments

Comments
 (0)