Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge pull request #17492 from [BEAM-13945] (FIX) Update Java… #18038

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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