beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [beam] branch master updated: [BEAM-7729] Fixes the bug by checking the value first before parsing it.
Date Fri, 12 Jul 2019 16:30:02 GMT
This is an automated email from the ASF dual-hosted git repository.

anton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 2215b77  [BEAM-7729] Fixes the bug by checking the value first before parsing it.
     new 60f70bf  Merge pull request #9045 from riazela/BigQueryNullableBugFix
2215b77 is described below

commit 2215b775cc10809ca330c916b45de7b914e56a83
Author: Alireza Samadian <alireza4263@gmail.com>
AuthorDate: Thu Jul 11 16:43:29 2019 -0700

    [BEAM-7729] Fixes the bug by checking the value first before parsing it.
---
 .../java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java
index 07102b3..6ff968b 100644
--- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java
+++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java
@@ -473,6 +473,14 @@ public class BigQueryUtils {
   public static Object convertAvroFormat(
       Field beamField, Object avroValue, BigQueryUtils.ConversionOptions options) {
     TypeName beamFieldTypeName = beamField.getType().getTypeName();
+    if (avroValue == null) {
+      if (beamField.getType().getNullable()) {
+        return null;
+      } else {
+        throw new IllegalArgumentException(
+            String.format("Field %s not nullable", beamField.getName()));
+      }
+    }
     switch (beamFieldTypeName) {
       case INT16:
       case INT32:


Mime
View raw message