Skip to content
Closed
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
4 changes: 2 additions & 2 deletions docs/streaming-programming-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,8 @@ unifiedStream.print();
{% highlight python %}
numStreams = 5
kafkaStreams = [KafkaUtils.createStream(...) for _ in range (numStreams)]
unifiedStream = streamingContext.union(kafkaStreams)
unifiedStream.print()
unifiedStream = streamingContext.union(*kafkaStreams)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@C-kang actually I don't know Python syntax well enough to be sure about this -- this is varargs syntax?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srowen right. The method is: def union(self, *dstreams), so it expects a variable number of dstreams passed in as arguments. If you pass in a list of dstreams without unpacking it, then vargs= [kafkaStreams, ] as opposed to vargs = [stream1, stream2, stream3, ...]. In the method then, len(vargs) == 1, so it just returns [kafkaStreams] as the unifiedStream without actually performing the union. And then unifiedStream.pprint() will fail because unifiedStream is not a dstream but a list.

unifiedStream.pprint()
{% endhighlight %}
</div>
</div>
Expand Down