You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/04/03 21:42:14 UTC

[GitHub] [beam] pabloem commented on a change in pull request #11244: [BEAM-3097] _ReadFromBigQuery supports valueprovider for table

pabloem commented on a change in pull request #11244: [BEAM-3097] _ReadFromBigQuery supports valueprovider for table
URL: https://github.com/apache/beam/pull/11244#discussion_r403350428
 
 

 ##########
 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:
   It is supported now. In this case, the `self.query` parameter is wrapped by a ValueProvider already. This does not work for `self.table` because it may be a non-string.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services