From 374160b6a41f22f16821572ff5b40480d1897af7 Mon Sep 17 00:00:00 2001 From: Stephen Judkins Date: Tue, 19 Oct 2021 15:04:51 -0700 Subject: [PATCH 1/9] fix: BQ/proto schema names should be compared lowercase --- .../google/cloud/bigquery/storage/v1/JsonToProtoMessage.java | 2 +- .../cloud/bigquery/storage/v1beta2/JsonToProtoMessage.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java index d891fbf972..91a432c258 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java @@ -124,7 +124,7 @@ private static DynamicMessage convertJsonToProtoMessageImpl( if (tableSchema != null) { // protoSchema is generated from tableSchema so their field ordering should match. fieldSchema = tableSchema.get(field.getIndex()); - if (!fieldSchema.getName().equals(field.getName())) { + if (!fieldSchema.getName().toLowerCase().equals(field.getName())) { throw new ValidationException( "Field at index " + field.getIndex() diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessage.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessage.java index 7a66927486..7d07130233 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessage.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessage.java @@ -123,7 +123,7 @@ private static DynamicMessage convertJsonToProtoMessageImpl( if (tableSchema != null) { // protoSchema is generated from tableSchema so their field ordering should match. fieldSchema = tableSchema.get(field.getIndex()); - if (!fieldSchema.getName().equals(field.getName())) { + if (!fieldSchema.getName().toLowerCase().equals(field.getName())) { throw new ValidationException( "Field at index " + field.getIndex() From 7e602d9a90be4625ef82773723f3a6e4423f21b5 Mon Sep 17 00:00:00 2001 From: Stephen Judkins Date: Wed, 20 Oct 2021 09:12:34 -0700 Subject: [PATCH 2/9] fix: add test for mixed-cased field name --- .../storage/v1/JsonToProtoMessageTest.java | 18 ++++++++++++++++++ .../src/test/proto/jsonTest.proto | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java index 2101e3077a..868905feda 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java @@ -552,6 +552,24 @@ public void testNumericMismatch() throws Exception { } } + @Test public void testMixedCasedFieldNames() throws Exception { + TableFieldSchema field = TableFieldSchema + .newBuilder() + .setName("fooBar") + .setType(TableFieldSchema.Type.STRING) + .setMode(TableFieldSchema.Mode.NULLABLE) + .build(); + TableSchema tableSchema = TableSchema.newBuilder().addFields(field).build(); + + JSONObject json = new JSONObject(); + json.put("fooBar", "hello"); + + DynamicMessage protoMsg = JsonToProtoMessage.convertJsonToProtoMessage( + TestMixedCaseFieldNames.getDescriptor(), tableSchema, json + ); + + } + @Test public void testBigNumericMismatch() throws Exception { TableFieldSchema field = diff --git a/google-cloud-bigquerystorage/src/test/proto/jsonTest.proto b/google-cloud-bigquerystorage/src/test/proto/jsonTest.proto index c08dd7648f..29efcdfb9c 100644 --- a/google-cloud-bigquerystorage/src/test/proto/jsonTest.proto +++ b/google-cloud-bigquerystorage/src/test/proto/jsonTest.proto @@ -156,3 +156,7 @@ message TestNumeric { message TestBignumeric { repeated bytes bignumeric = 1; } + +message TestMixedCaseFieldNames { + required string foobar = 1; +} From c51017a2974741806dd3ffeb24fbffa7c9342ce1 Mon Sep 17 00:00:00 2001 From: Stephen Judkins Date: Wed, 20 Oct 2021 11:59:29 -0700 Subject: [PATCH 3/9] fix: add test to v1beta2 as well --- .../v1beta2/JsonToProtoMessageTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java index c01f5ecbd3..27233e61a2 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java @@ -574,6 +574,24 @@ public void testBigNumericMismatch() throws Exception { } } + @Test public void testMixedCasedFieldNames() throws Exception { + com.google.cloud.bigquery.storage.v1.TableFieldSchema field = com.google.cloud.bigquery.storage.v1.TableFieldSchema + .newBuilder() + .setName("fooBar") + .setType(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Type.STRING) + .setMode(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Mode.NULLABLE) + .build(); + com.google.cloud.bigquery.storage.v1.TableSchema tableSchema = com.google.cloud.bigquery.storage.v1.TableSchema.newBuilder().addFields(field).build(); + + JSONObject json = new JSONObject(); + json.put("fooBar", "hello"); + + DynamicMessage protoMsg = com.google.cloud.bigquery.storage.v1.JsonToProtoMessage.convertJsonToProtoMessage( + TestMixedCaseFieldNames.getDescriptor(), tableSchema, json + ); + + } + @Test public void testDouble() throws Exception { TestDouble expectedProto = TestDouble.newBuilder().setDouble(1.2).setFloat(3.4f).build(); From f53df7f2b5af6a0503815966d602f45206a6082f Mon Sep 17 00:00:00 2001 From: Stephen Judkins Date: Wed, 20 Oct 2021 15:11:22 -0700 Subject: [PATCH 4/9] format --- .../storage/v1/JsonToProtoMessageTest.java | 22 +++++++++---------- .../v1beta2/JsonToProtoMessageTest.java | 17 +++++++------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java index 868905feda..e52d3cf59b 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java @@ -552,22 +552,22 @@ public void testNumericMismatch() throws Exception { } } - @Test public void testMixedCasedFieldNames() throws Exception { - TableFieldSchema field = TableFieldSchema - .newBuilder() - .setName("fooBar") - .setType(TableFieldSchema.Type.STRING) - .setMode(TableFieldSchema.Mode.NULLABLE) - .build(); + @Test + public void testMixedCasedFieldNames() throws Exception { + TableFieldSchema field = + TableFieldSchema.newBuilder() + .setName("fooBar") + .setType(TableFieldSchema.Type.STRING) + .setMode(TableFieldSchema.Mode.NULLABLE) + .build(); TableSchema tableSchema = TableSchema.newBuilder().addFields(field).build(); JSONObject json = new JSONObject(); json.put("fooBar", "hello"); - DynamicMessage protoMsg = JsonToProtoMessage.convertJsonToProtoMessage( - TestMixedCaseFieldNames.getDescriptor(), tableSchema, json - ); - + DynamicMessage protoMsg = + JsonToProtoMessage.convertJsonToProtoMessage( + TestMixedCaseFieldNames.getDescriptor(), tableSchema, json); } @Test diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java index 27233e61a2..47064e2a50 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1beta2/JsonToProtoMessageTest.java @@ -574,22 +574,23 @@ public void testBigNumericMismatch() throws Exception { } } - @Test public void testMixedCasedFieldNames() throws Exception { - com.google.cloud.bigquery.storage.v1.TableFieldSchema field = com.google.cloud.bigquery.storage.v1.TableFieldSchema - .newBuilder() + @Test + public void testMixedCasedFieldNames() throws Exception { + com.google.cloud.bigquery.storage.v1.TableFieldSchema field = + com.google.cloud.bigquery.storage.v1.TableFieldSchema.newBuilder() .setName("fooBar") .setType(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Type.STRING) .setMode(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Mode.NULLABLE) .build(); - com.google.cloud.bigquery.storage.v1.TableSchema tableSchema = com.google.cloud.bigquery.storage.v1.TableSchema.newBuilder().addFields(field).build(); + com.google.cloud.bigquery.storage.v1.TableSchema tableSchema = + com.google.cloud.bigquery.storage.v1.TableSchema.newBuilder().addFields(field).build(); JSONObject json = new JSONObject(); json.put("fooBar", "hello"); - DynamicMessage protoMsg = com.google.cloud.bigquery.storage.v1.JsonToProtoMessage.convertJsonToProtoMessage( - TestMixedCaseFieldNames.getDescriptor(), tableSchema, json - ); - + DynamicMessage protoMsg = + com.google.cloud.bigquery.storage.v1.JsonToProtoMessage.convertJsonToProtoMessage( + TestMixedCaseFieldNames.getDescriptor(), tableSchema, json); } @Test From f18710cd3f30a090b850f1c4de035fc6e0f08ef9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 25 Oct 2021 15:43:30 +0000 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d2a291cd4..098a71eab0 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-bigquerystorage' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-bigquerystorage:2.4.0' +implementation 'com.google.cloud:google-cloud-bigquerystorage:2.4.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.4.0" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.4.2" ``` ## Authentication From 2385a331fa512e1a0bddbe12b22ee57f7d2aa195 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 25 Oct 2021 15:43:43 +0000 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d2a291cd4..098a71eab0 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-bigquerystorage' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-bigquerystorage:2.4.0' +implementation 'com.google.cloud:google-cloud-bigquerystorage:2.4.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.4.0" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.4.2" ``` ## Authentication From 1c935112320ec09370c9a8b18831545baf804d3e Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Mon, 25 Oct 2021 12:07:08 -0400 Subject: [PATCH 7/9] Update JsonToProtoMessageTest.java --- .../cloud/bigquery/storage/v1/JsonToProtoMessageTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java index e52d3cf59b..e71f927e6d 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java @@ -553,7 +553,7 @@ public void testNumericMismatch() throws Exception { } @Test - public void testMixedCasedFieldNames() throws Exception { + public void testMixedCaseFieldNames() throws Exception { TableFieldSchema field = TableFieldSchema.newBuilder() .setName("fooBar") From 2eba5ea87e6746c342dd081bfbccb371c3ca86f3 Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Mon, 25 Oct 2021 14:34:02 -0400 Subject: [PATCH 8/9] Update dependencies.sh --- .kokoro/dependencies.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index 99bd46c76b..45503ca956 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -38,15 +38,14 @@ function determineMavenOpts() { | sed -E 's/^(1\.[0-9]\.0).*$/\1/g' ) - case $javaVersion in - "17") + if [[ $javaVersion == 17* ]] + then # MaxPermSize is no longer supported as of jdk 17 echo -n "-Xmx1024m" ;; - *) + else echo -n "-Xmx1024m -XX:MaxPermSize=128m" - ;; - esac + fi } export MAVEN_OPTS=$(determineMavenOpts) From c6de143ae9f08cf263318f47bcbba55b2ee1b72e Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Mon, 25 Oct 2021 14:35:56 -0400 Subject: [PATCH 9/9] Update dependencies.sh --- .kokoro/dependencies.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index 45503ca956..f20d192c3d 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -42,7 +42,6 @@ function determineMavenOpts() { then # MaxPermSize is no longer supported as of jdk 17 echo -n "-Xmx1024m" - ;; else echo -n "-Xmx1024m -XX:MaxPermSize=128m" fi