Skip to content

Commit 53b54cb

Browse files
author
Alain
committed
[PYSPARK] Fix a typo in "fold" function in rdd.py
This will make the “fold” function consistent with the "fold" in rdd.scala and other "aggregate" functions where “acc” goes first. Otherwise, users have to write a lambda function like “lambda x, y: op(y, x)” if they want to use “zeroValue” to the result type.
1 parent 6fe690d commit 53b54cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/pyspark/rdd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def fold(self, zeroValue, op):
827827
def func(iterator):
828828
acc = zeroValue
829829
for obj in iterator:
830-
acc = op(obj, acc)
830+
acc = op(acc, obj)
831831
yield acc
832832
vals = self.mapPartitions(func).collect()
833833
return reduce(op, vals, zeroValue)

0 commit comments

Comments
 (0)