claudevdm commented on code in PR #38015:
URL: https://github.com/apache/beam/pull/38015#discussion_r3017810656
##########
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:
I dont think so because it either outputs batches or outputs rows.
Output tags would make sense if it is possible to emit batches and rows, and
they need to be routed differently?
--
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]