chamikaramj commented on a change in pull request #11244: [BEAM-3097]
_ReadFromBigQuery supports valueprovider for table
URL: https://github.com/apache/beam/pull/11244#discussion_r402668608
##########
File path: sdks/python/apache_beam/io/gcp/bigquery.py
##########
@@ -641,12 +641,19 @@ def __init__(
def estimate_size(self):
bq = bigquery_tools.BigQueryWrapper()
if self.table_reference is not None:
+ table_ref = self.table_reference
+ if (isinstance(self.table_reference, vp.ValueProvider) and
+ self.table_reference.is_accessible()):
+ table_ref = bigquery_tools.parse_table_reference(
+ self.table_reference.get(), self.dataset, self.project)
+ elif isinstance(self.table_reference, vp.ValueProvider):
+ # Size estimation is best effort. We return 0 as we have no
+ # access to the table that we're querying.
+ return 0
table = bq.get_table(
- self.table_reference.projectId,
- self.table_reference.datasetId,
- self.table_reference.tableId)
+ table_ref.projectId, table_ref.datasetId, table_ref.tableId)
return int(table.numBytes)
- else:
+ elif self.query is not None and self.query.is_accessible():
Review comment:
Shouldn't we support ValueProvider for queries as well ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services