Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sdks/python/apache_beam/io/iobase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,12 @@ def _expand_bounded(self, pcoll, min_shards):
keyed_pcoll = pcoll | core.Map(lambda x: (None, x))
else:
keyed_pcoll = pcoll | core.ParDo(_RoundRobinKeyFn(), count=min_shards)
# pcoll.windowing checks pcoll.producer which may be absent when expand()
# is called directly (e.g. in tests)
if pcoll.producer is None or not keyed_pcoll.windowing.is_default():
keyed_pcoll = keyed_pcoll | core.WindowInto(window.GlobalWindows())
write_result_coll = (
keyed_pcoll
| core.WindowInto(window.GlobalWindows())
| core.GroupByKey()
| 'WriteBundles' >> core.ParDo(
_WriteKeyedBundleDoFn(self.sink), AsSingleton(init_result_coll)))
Expand All @@ -1200,9 +1203,10 @@ def _expand_bounded(self, pcoll, min_shards):
"*** WriteImpl min_shards undef so it's 1, and we write per Bundle")
min_shards = 1

if pcoll.producer is None or not pcoll.windowing.is_default():
pcoll = pcoll | core.WindowInto(window.GlobalWindows())
write_result_coll = (
pcoll
| core.WindowInto(window.GlobalWindows())
| 'WriteBundles' >> core.ParDo(
_WriteBundleDoFn(self.sink), AsSingleton(init_result_coll))
| 'Pair' >> core.Map(lambda x: (None, x))
Expand Down
Loading