ahmedabu98 commented on code in PR #38015:
URL: https://github.com/apache/beam/pull/38015#discussion_r3018450656
##########
sdks/python/apache_beam/io/gcp/bigquery_change_history.py:
##########
@@ -808,19 +873,27 @@ def process(
'[Read] try_claim(%d) succeeded: reading stream %s', i, stream_name)
stream_rows = 0
- for row in self._read_stream(stream_name):
- ts = row.get(self._change_timestamp_column)
- if ts is None:
- raise ValueError(
- 'Row missing %r column. Row keys: %s' %
- (self._change_timestamp_column, list(row.keys())))
- if isinstance(ts, datetime.datetime):
- ts = Timestamp.from_utc_datetime(ts)
-
- yield TimestampedValue(row, ts)
- stream_rows += 1
- total_rows += 1
- Metrics.counter('BigQueryChangeHistory', 'rows_emitted').inc(total_rows)
+ if self._emit_raw_batches:
+ stream_batches = 0
+ for raw_batch in self._read_stream_raw(stream_name):
+ yield TimestampedValue(raw_batch, element.range_start)
+ stream_batches += 1
+ Metrics.counter('BigQueryChangeHistory',
+ 'batches_emitted').inc(stream_batches)
+ else:
+ for row in self._read_stream(stream_name):
+ ts = row.get(self._change_timestamp_column)
+ if ts is None:
+ raise ValueError(
+ 'Row missing %r column. Row keys: %s' %
+ (self._change_timestamp_column, list(row.keys())))
+ if isinstance(ts, datetime.datetime):
+ ts = Timestamp.from_utc_datetime(ts)
+
+ yield TimestampedValue(row, ts)
+ stream_rows += 1
+ Metrics.counter('BigQueryChangeHistory',
+ 'rows_emitted').inc(stream_rows)
Review Comment:
Yeah that's fair. I think this part below just threw me off a little:
```python
if emit_raw:
read_sdf = read_sdf.with_output_types(Tuple[bytes, bytes])
else:
read_sdf = read_sdf.with_output_types(Dict[str, Any])
```
But we can go with your current approach
--
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]