diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a34faf5af..f4d277f8cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +### [1.111.3](https://www.github.com/googleapis/java-bigquery/compare/v1.111.2...v1.111.3) (2020-05-04) + + +### Bug Fixes + +* null type in timepartitioning frompb ([#305](https://www.github.com/googleapis/java-bigquery/issues/305)) ([6315842](https://www.github.com/googleapis/java-bigquery/commit/6315842dfa62a433a1ba507b861cf96a3d7cb03d)) + + +### Dependencies + +* update dependency com.google.apis:google-api-services-bigquery to v2-rev20200415-1.30.9 ([#307](https://www.github.com/googleapis/java-bigquery/issues/307)) ([fccb0b4](https://www.github.com/googleapis/java-bigquery/commit/fccb0b4d08b41e4836ac9490befca47306f14afd)) +* update dependency com.google.auto.value:auto-value to v1.7.1 ([#308](https://www.github.com/googleapis/java-bigquery/issues/308)) ([5a0ed06](https://www.github.com/googleapis/java-bigquery/commit/5a0ed060eb2c966092af66bfae2896ea8af70c7e)) + ### [1.111.2](https://www.github.com/googleapis/java-bigquery/compare/v1.111.1...v1.111.2) (2020-04-29) diff --git a/README.md b/README.md index 1b7b5f81b6..9bdb28ee0e 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,11 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-bigquery:1.111.2' +compile 'com.google.cloud:google-cloud-bigquery:1.111.3' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "1.111.2" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "1.111.3" ``` [//]: # ({x-version-update-end}) diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml index 1b7aefc602..6d21659a50 100644 --- a/google-cloud-bigquery/pom.xml +++ b/google-cloud-bigquery/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-bigquery - 1.111.2 + 1.111.3 jar BigQuery https://github.com/googleapis/java-bigquery @@ -11,7 +11,7 @@ com.google.cloud google-cloud-bigquery-parent - 1.111.2 + 1.111.3 google-cloud-bigquery diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java index 1c465343a5..4e26f831f1 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java @@ -285,17 +285,6 @@ static StandardTableDefinition fromPb(Table tablePb) { + " in table " + tablePb.getTableReference().getTableId(), e); - } catch (NullPointerException e) { - throw new NullPointerException( - "Null pointer - Got unexpected time partitioning " - + tablePb.getTimePartitioning().toString() - + " in project " - + tablePb.getTableReference().getProjectId() - + " in dataset " - + tablePb.getTableReference().getDatasetId() - + " in table " - + tablePb.getTableReference().getTableId() - + e.toString()); } } if (tablePb.getRangePartitioning() != null) { diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TimePartitioning.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TimePartitioning.java index dd9d4a73cb..43f3421294 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TimePartitioning.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TimePartitioning.java @@ -142,7 +142,7 @@ static TimePartitioning fromPb( if (Data.isNull(expirationMs)) { expirationMs = null; } - return newBuilder(Type.valueOf(partitioningPb.getType())) + return newBuilder(Type.valueOf(firstNonNull(partitioningPb.getType(), Type.DAY.name()))) .setExpirationMs(expirationMs) .setField(partitioningPb.getField()) .setRequirePartitionFilter(partitioningPb.getRequirePartitionFilter()) diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java index 7ab3e8ef28..999ea9a03b 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java @@ -116,11 +116,22 @@ public class BigQueryImplTest { private static final Long TABLE_CREATION_TIME = 1546275600000L; private static final TimePartitioning TIME_PARTITIONING = TimePartitioning.of(TimePartitioning.Type.DAY, EXPIRATION_MS); + private static final com.google.api.services.bigquery.model.TimePartitioning PB_TIMEPARTITIONING = + new com.google.api.services.bigquery.model.TimePartitioning() + .setType(null) + .setField("timestampField"); + private static final TimePartitioning TIME_PARTITIONING_NULL_TYPE = + TimePartitioning.fromPb(PB_TIMEPARTITIONING); private static final StandardTableDefinition TABLE_DEFINITION_WITH_PARTITIONING = StandardTableDefinition.newBuilder() .setSchema(TABLE_SCHEMA) .setTimePartitioning(TIME_PARTITIONING) .build(); + private static final StandardTableDefinition TABLE_DEFINITION_WITH_PARTITIONING_NULL_TYPE = + StandardTableDefinition.newBuilder() + .setSchema(TABLE_SCHEMA) + .setTimePartitioning(TIME_PARTITIONING_NULL_TYPE) + .build(); private static final RangePartitioning.Range RANGE = RangePartitioning.Range.newBuilder().setStart(1L).setInterval(2L).setEnd(10L).build(); private static final RangePartitioning RANGE_PARTITIONING = @@ -142,7 +153,10 @@ public class BigQueryImplTest { TableInfo.newBuilder(TABLE_ID, TABLE_DEFINITION_WITH_PARTITIONING) .setCreationTime(TABLE_CREATION_TIME) .build(); - + private static final TableInfo TABLE_INFO_WITH_PARTITIONS_NULL_TYPE = + TableInfo.newBuilder(TABLE_ID, TABLE_DEFINITION_WITH_PARTITIONING_NULL_TYPE) + .setCreationTime(TABLE_CREATION_TIME) + .build(); private static final ModelId OTHER_MODEL_ID = ModelId.of(DATASET, OTHER_MODEL); private static final ModelId MODEL_ID_WITH_PROJECT = ModelId.of(PROJECT, DATASET, MODEL); @@ -912,6 +926,22 @@ public void testListTablesReturnedParameters() { assertArrayEquals(tableList.toArray(), Iterables.toArray(page.getValues(), Table.class)); } + @Test + public void testListTablesReturnedParametersNullType() { + bigquery = options.getService(); + ImmutableList tableList = + ImmutableList.of( + new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PARTITIONS_NULL_TYPE))); + Tuple> result = + Tuple.of(CURSOR, Iterables.transform(tableList, TableInfo.TO_PB_FUNCTION)); + EasyMock.expect(bigqueryRpcMock.listTables(PROJECT, DATASET, TABLE_LIST_OPTIONS)) + .andReturn(result); + EasyMock.replay(bigqueryRpcMock); + Page
page = bigquery.listTables(DATASET, TABLE_LIST_PAGE_SIZE, TABLE_LIST_PAGE_TOKEN); + assertEquals(CURSOR, page.getNextPageToken()); + assertArrayEquals(tableList.toArray(), Iterables.toArray(page.getValues(), Table.class)); + } + @Test public void testListTablesWithRangePartitioning() { bigquery = options.getService(); diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java index d1dd0cc29a..397e69d1ef 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java @@ -152,34 +152,6 @@ public void testFromPbWithUnexpectedTimePartitioningTypeRaisesInvalidArgumentExc fail("testFromPb illegal argument exception did not throw!"); } - @Test - public void testFromPbWithNullTimePartitioningTypeRaisesNullPointerException() { - Table invalidTable = - new Table() - .setType("TABLE") - .setTableReference( - new TableReference() - .setProjectId("NULL_PTR_TEST_PROJECT") - .setDatasetId("NULL_PTR_TEST_DATASET") - .setTableId("NULL_PTR_TEST_TABLE")) - .setTimePartitioning( - new com.google.api.services.bigquery.model.TimePartitioning().setType(null)); - try { - StandardTableDefinition.fromPb(invalidTable); - } catch (NullPointerException ne) { - assertThat( - ne.getMessage(), - allOf( - containsString("Null pointer - Got unexpected time partitioning"), - containsString("null"), - containsString("NULL_PTR_TEST_PROJECT"), - containsString("NULL_PTR_TEST_DATASET"), - containsString("NULL_PTR_TEST_TABLE"))); - return; - } - fail("testFromPb null pointer exception did not throw!"); - } - @Test public void testFromPbWithNullEstimatedRowsAndBytes() { StandardTableDefinition.fromPb( diff --git a/pom.xml b/pom.xml index 72dbf5e7c0..e66a9560ef 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloudgoogle-cloud-bigquery-parentpom - 1.111.2 + 1.111.3BigQuery Parenthttps://github.com/googleapis/java-bigquery @@ -74,9 +74,9 @@ 1.4.4 1.3.2 1.18 - v2-rev20200324-1.30.9 + v2-rev20200415-1.30.9 - 1.7 + 1.7.1 ${auto-value.version} 1.0-rc6 @@ -116,7 +116,7 @@ com.google.cloud google-cloud-bigquery - 1.111.2 + 1.111.3 diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 7c4826a39d..7b20949f6e 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -45,7 +45,7 @@ com.google.cloud google-cloud-bigquery - 1.111.1 + 1.111.2 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index f2a1f96a9b..13224ffde2 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigquery - 1.111.2 + 1.111.3 diff --git a/synth.metadata b/synth.metadata index 3da64aa088..bcc7637a9b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-bigquery.git", - "sha": "9d37e45bc07de3d6b4fb2aac4c69df7b2ef80c9f" + "sha": "2b319ce21e2f540b7de4dfcef02c68a6cf8a1564" } }, { diff --git a/versions.txt b/versions.txt index 323882b01d..6a4068d7fe 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-bigquery:1.111.2:1.111.2 \ No newline at end of file +google-cloud-bigquery:1.111.3:1.111.3 \ No newline at end of file