Skip to content

Commit 517a67f

Browse files
committed
Added tests for python groupWith
1 parent 2f402d5 commit 517a67f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/pyspark/rdd.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,14 @@ def mapValues(self, f):
13251325

13261326
def groupWith(self, other, *others):
13271327
"""
1328-
Alias for cogroup.
1328+
Alias for cogroup but with support for multiple RDDs.
1329+
1330+
>>> x = sc.parallelize([("a", 1), ("b", 4)])
1331+
>>> y = sc.parallelize([("a", 2)])
1332+
>>> z = sc.parallelize([("b", 42)])
1333+
>>> map((lambda (x,y): (x, (list(y[0]), list(y[1]), list(y[2])))), sorted(list(x.groupWith(y, z).collect())))
1334+
[('a', ([1], [2], [])), ('b', ([4], [], [42]))]
1335+
13291336
"""
13301337
return python_cogroup((self, other) + others, numPartitions=None)
13311338

0 commit comments

Comments
 (0)