[ 
https://issues.apache.org/jira/browse/BEAM-10917?focusedWorklogId=631249&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-631249
 ]

ASF GitHub Bot logged work on BEAM-10917:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 29/Jul/21 17:44
            Start Date: 29/Jul/21 17:44
    Worklog Time Spent: 10m 
      Work Description: vachan-shetty commented on a change in pull request 
#15185:
URL: https://github.com/apache/beam/pull/15185#discussion_r679355415



##########
File path: sdks/python/apache_beam/io/gcp/bigquery.py
##########
@@ -1056,23 +1054,43 @@ def deserialize_rows(self, read_rows_response, reader):
 
   def read(self, range_tracker):
     storage_client = bq_storage.BigQueryReadClient()
-    read_rows_iterator = iter(storage_client.read_rows(self.read_stream_name))
-    read_rows_response = next(read_rows_iterator)
-    avro_schema = avro.schema.Parse(read_rows_response.avro_schema.schema)
-    reader = avroio.DatumReader(avro_schema)
-    while True:
-      # self.deserialize_rows(read_rows_response, reader)
-      decoder = avroio.BinaryDecoder(
-          io.BytesIO(read_rows_response.avro_rows.serialized_binary_rows))
-      current_row = 0
-      while current_row < read_rows_response.row_count:
-        self.deserialized_rows.append(reader.read(decoder))
-        current_row += 1
-      read_rows_response = next(read_rows_iterator, None)
-      if read_rows_response is None:
-        break
-
-    return iter(self.deserialized_rows)
+    row_reader = _ReadRowsResponseReader(
+        storage_client.read_rows(self.read_stream_name))
+    return iter(row_reader)
+
+
+class _ReadRowsResponseReader():
+  def __init__(self, read_rows_responses):
+    self.read_rows_iterator = iter(read_rows_responses)
+    self.read_rows_response = next(self.read_rows_iterator)

Review comment:
       There doesn't seem to be a simple way to handle this case in the 
`__next__` call. I've gone ahead and added some error handling to account for 
the possibility of an empty response. Added a test for the same.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 631249)
    Time Spent: 1.5h  (was: 1h 20m)

> Implement a BigQuery bounded source using the BigQuery storage API
> ------------------------------------------------------------------
>
>                 Key: BEAM-10917
>                 URL: https://issues.apache.org/jira/browse/BEAM-10917
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-py-gcp
>            Reporter: Kenneth Jung
>            Priority: P3
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> The Java SDK contains a bounded source implementation which uses the BigQuery 
> storage API to read from BigQuery. We should implement the same for Python.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to