Skip to content

Commit a94d896

Browse files
author
Nikita Grover
committed
Add Dataflow warning in WriteToPubSub.expand() for ordering key support
1 parent 26a34f2 commit a94d896

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

sdks/python/apache_beam/io/gcp/pubsub.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,17 @@ def bytes_to_proto_str(element: Union[bytes, str]) -> bytes:
430430
def expand(self, pcoll):
431431
# Store pipeline options for use in DoFn
432432
self.pipeline_options = pcoll.pipeline.options if pcoll.pipeline else None
433-
433+
# Warn Dataflow users to use the XLang path for ordering key support,
434+
# since _PubSubWriteDoFn._flush() is not used by Dataflow's implementation.
435+
import logging
436+
runner = self.pipeline_options.get_all_options().get(
437+
'runner', '') if self.pipeline_options else ''
438+
if 'Dataflow' in str(runner):
439+
logging.warning(
440+
'WriteToPubSub ordering_key support is not available on Dataflow '
441+
'via this transform. Use the XLang WriteToPubSub path instead: '
442+
'apache_beam.io.external.gcp.pubsub.WriteToPubSub with '
443+
'publish_with_ordering_key=True.')
434444
if self.with_attributes:
435445
pcoll = pcoll | 'ToProtobufX' >> ParDo(
436446
_AddMetricsAndMap(

0 commit comments

Comments
 (0)