diff --git a/sdks/python/apache_beam/io/gcp/bigquery.py b/sdks/python/apache_beam/io/gcp/bigquery.py index 27e4a26151455..0a0b1f8b7a7ea 100644 --- a/sdks/python/apache_beam/io/gcp/bigquery.py +++ b/sdks/python/apache_beam/io/gcp/bigquery.py @@ -293,6 +293,11 @@ def compute_table_name(row): from apache_beam.utils.histogram import Histogram from apache_beam.utils.histogram import LinearBucket +try: + from apache_beam.io.gcp.internal.clients.bigquery import TableReference +except ImportError: + TableReference = None + __all__ = [ 'TableRowJsonCoder', 'BigQueryDisposition', @@ -1602,7 +1607,7 @@ def _compute_method(self, experiments, is_streaming_pipeline): def expand(self, pcoll): p = pcoll.pipeline - if (isinstance(self.table_reference, bigquery.TableReference) and + if (isinstance(self.table_reference, TableReference) and self.table_reference.projectId is None): self.table_reference.projectId = pcoll.pipeline.options.view_as( GoogleCloudOptions).project @@ -1955,7 +1960,7 @@ def __init__( self, query: str = None, use_standard_sql: bool = False, - table: Union[str, bigquery.TableReference] = None, + table: Union[str, TableReference] = None, flatten_results: bool = False): """ Only one of query or table should be specified.