From e00a81f400c0dc3fd72d7de43605574bf2626d6b Mon Sep 17 00:00:00 2001 From: Edward Cui Date: Mon, 19 Feb 2024 23:42:38 -0500 Subject: [PATCH] Allow JSON type in TableSchema for WriteToBigQuery with FILE_LOAD method in Python SDK (#30340) * remove JSON type checking and raise error in WriteoToBigQuery with FILE_LOADS method * Changing to warning instead * update warning message. Nw should be the same with Java sdk * fix lie length * fixing formatting --- sdks/python/apache_beam/io/gcp/bigquery.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sdks/python/apache_beam/io/gcp/bigquery.py b/sdks/python/apache_beam/io/gcp/bigquery.py index 7648ab4064da..ad9e31d52852 100644 --- a/sdks/python/apache_beam/io/gcp/bigquery.py +++ b/sdks/python/apache_beam/io/gcp/bigquery.py @@ -2178,13 +2178,11 @@ def expand(self, pcoll): def find_in_nested_dict(schema): for field in schema['fields']: if field['type'] == 'JSON': - raise ValueError( - 'Found JSON type in table schema. JSON data ' - 'insertion is currently not supported with ' - 'FILE_LOADS write method. This is supported with ' - 'STREAMING_INSERTS. For more information: ' - 'https://cloud.google.com/bigquery/docs/reference/' - 'standard-sql/json-data#ingest_json_data') + logging.warning( + 'Found JSON type in TableSchema for "File_LOADS" write ' + 'method. Make sure the TableSchema field is a parsed ' + 'JSON to ensure the read as a JSON type. Otherwise it ' + 'will read as a raw (escaped) string.') elif field['type'] == 'STRUCT': find_in_nested_dict(field)