Skip to content
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
12 changes: 11 additions & 1 deletion sdks/python/apache_beam/io/gcp/bigquery_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
except ImportError:
pass

try:
# TODO(pabloem): Remove this workaround after Python 2.7 support ends.
from json.decoder import JSONDecodeError
except ImportError:
JSONDecodeError = ValueError

# pylint: enable=wrong-import-order, wrong-import-position

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -134,7 +140,11 @@ def parse_table_schema_from_json(schema_string):
Returns:
A TableSchema of the BigQuery export from either the Query or the Table.
"""
json_schema = json.loads(schema_string)
try:
json_schema = json.loads(schema_string)
except JSONDecodeError as e:
raise ValueError(
'Unable to parse JSON schema: %s - %r' % (schema_string, e))

def _parse_schema_field(field):
"""Parse a single schema field from dictionary.
Expand Down