From 688d1836614ebd25268142286307afa4804ba290 Mon Sep 17 00:00:00 2001 From: Pablo E Date: Fri, 3 Jun 2022 09:10:13 -0700 Subject: [PATCH] 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 d68a005915748..463a5c80f87b8 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.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 @@ private WriteResult continueExpandTyped( "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 batchLoads = @@ -3011,25 +3009,6 @@ private WriteResult continueExpandTyped( } } - 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);