Skip to content

Commit

Permalink
Merge pull request #18038 from Revert "Merge pull request #17492 from [
Browse files Browse the repository at this point in the history
…BEAM-13945] (FIX) Update Java…

Revert "Merge pull request #17492 from [BEAM-13945] (FIX) Update Java…
  • Loading branch information
pabloem authored Jun 3, 2022
2 parents c072c36 + 688d183 commit 6d6a54d
Showing 1 changed file with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -2923,12 +2921,12 @@ private <DestinationT> 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<DestinationT, T> batchLoads =
Expand Down Expand Up @@ -3011,25 +3009,6 @@ private <DestinationT> 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);
Expand Down

0 comments on commit 6d6a54d

Please sign in to comment.