Skip to content

Commit

Permalink
Added tests for python groupWith
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaz committed Jun 19, 2014
1 parent 2f402d5 commit 517a67f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/pyspark/rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,14 @@ def mapValues(self, f):

def groupWith(self, other, *others):
"""
Alias for cogroup.
Alias for cogroup but with support for multiple RDDs.
>>> x = sc.parallelize([("a", 1), ("b", 4)])
>>> y = sc.parallelize([("a", 2)])
>>> z = sc.parallelize([("b", 42)])
>>> map((lambda (x,y): (x, (list(y[0]), list(y[1]), list(y[2])))), sorted(list(x.groupWith(y, z).collect())))
[('a', ([1], [2], [])), ('b', ([4], [], [42]))]
"""
return python_cogroup((self, other) + others, numPartitions=None)

Expand Down

0 comments on commit 517a67f

Please sign in to comment.