Skip to content

Commit

Permalink
Updated Regex and test
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdheeraj authored Jul 6, 2022
1 parent 3391663 commit 930ad5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/io/gcp/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ class _CustomBigQueryStorageSource(BoundedSource):
Args:
table (str, TableReference): The ID of the table. The ID must contain only
letters ``a-z``, ``A-Z``, numbers ``0-9``, underscores ``_`` or white
spaces. If **dataset** argument is :data:`None` then the table
spaces. If **dataset** argument is :data:`None` then the table
argument must contain the entire table reference specified as:
``'PROJECT:DATASET.TABLE'`` or must specify a TableReference.
dataset (str): Optional ID of the dataset containing this table or
Expand Down
9 changes: 5 additions & 4 deletions sdks/python/apache_beam/io/gcp/bigquery_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,11 @@ def parse_table_reference(table, dataset=None, project=None):
# table argument will contain a full table reference instead of just a
# table name.
if dataset is None:
match = re.match(
r"""^((?P<project>.+):)?(?P<dataset>\w+)\.
(?P<table>[-\w\$]+( +\-*\w+)*)$""",
table)
regex = re.compile(
r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
(?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
re.X)
match = regex.match(table)
if not match:
raise ValueError(
'Expected a table reference (PROJECT:DATASET.TABLE or '
Expand Down

0 comments on commit 930ad5e

Please sign in to comment.