You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2022/06/03 16:44:55 UTC

[beam] branch master updated: Revert "Merge pull request #17492 from [BEAM-13945] (FIX) Update Java BQ connector to support new JSON type "

This is an automated email from the ASF dual-hosted git repository.

pabloem 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 688d1836614 Revert "Merge pull request #17492 from [BEAM-13945] (FIX) Update Java BQ connector to support new JSON type "
     new 6d6a54d21b4 Merge pull request #18038 from Revert "Merge pull request #17492 from [BEAM-13945] (FIX) Update Java…
688d1836614 is described below

commit 688d1836614ebd25268142286307afa4804ba290
Author: Pablo E <pa...@apache.org>
AuthorDate: Fri Jun 3 09:10:13 2022 -0700

    Revert "Merge pull request #17492 from [BEAM-13945] (FIX) Update Java BQ connector to support new JSON type "
    
    This reverts commit 12be69dcd14df43e314a4c3abb086a7066c2a6a0.
---
 .../beam/sdk/io/gcp/bigquery/BigQueryIO.java       | 31 ++++------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java
index d68a0059157..463a5c80f87 100644
--- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java
+++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java
@@ -127,8 +127,6 @@ import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterable
 import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Lists;
 import org.checkerframework.checker.nullness.qual.Nullable;
 import org.joda.time.Duration;
-import org.json.JSONArray;
-import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -2923,12 +2921,12 @@ public class BigQueryIO {
               "useAvroLogicalTypes can only be set with Avro output.");
         }
 
-        // Batch load jobs currently support JSON data insertion only with CSV files
         if (getJsonSchema() != null && getJsonSchema().isAccessible()) {
-          JSONObject schema = new JSONObject(getJsonSchema().get());
-          if (!schema.isEmpty()) {
-            validateNoJsonTypeInSchema(schema);
-          }
+          // Batch load jobs currently support JSON data insertion only with CSV files
+          checkArgument(
+              !getJsonSchema().get().contains("JSON"),
+              "Found JSON type in TableSchema. JSON data insertion is currently "
+                  + "not supported with batch loads.");
         }
 
         BatchLoads<DestinationT, T> batchLoads =
@@ -3011,25 +3009,6 @@ public class BigQueryIO {
       }
     }
 
-    private void validateNoJsonTypeInSchema(JSONObject schema) {
-      JSONArray fields = schema.getJSONArray("fields");
-
-      for (int i = 0; i < fields.length(); i++) {
-        JSONObject field = fields.getJSONObject(i);
-        checkArgument(
-            !field.getString("type").equals("JSON"),
-            "Found JSON type in TableSchema. JSON data insertion is currently "
-                + "not supported with 'FILE_LOADS' write method. This is supported with the "
-                + "other write methods, however. For more information, visit: "
-                + "https://cloud.google.com/bigquery/docs/reference/standard-sql/"
-                + "json-data#ingest_json_data");
-
-        if (field.getString("type").equals("STRUCT")) {
-          validateNoJsonTypeInSchema(field);
-        }
-      }
-    }
-
     @Override
     public void populateDisplayData(DisplayData.Builder builder) {
       super.populateDisplayData(builder);