diff options
author | zsxwing <zsxwing@gmail.com> | 2015-06-17 13:59:39 -0700 |
---|---|---|
committer | Andrew Or <andrew@databricks.com> | 2015-06-17 13:59:39 -0700 |
commit | 0fc4b96f3e3bf81724ac133a6acc97c1b77271b4 (patch) | |
tree | 7d5e783967ac602ce979fe0f15a3d3613f44a4f8 /python/pyspark/tests.py | |
parent | 2837e067099921dd4ab6639ac5f6e89f789d4ff4 (diff) | |
download | spark-0fc4b96f3e3bf81724ac133a6acc97c1b77271b4.tar.gz spark-0fc4b96f3e3bf81724ac133a6acc97c1b77271b4.tar.bz2 spark-0fc4b96f3e3bf81724ac133a6acc97c1b77271b4.zip |
[SPARK-8373] [PYSPARK] Add emptyRDD to pyspark and fix the issue when calling sum on an empty RDD
This PR fixes the sum issue and also adds `emptyRDD` so that it's easy to create a test case.
Author: zsxwing <zsxwing@gmail.com>
Closes #6826 from zsxwing/python-emptyRDD and squashes the following commits:
b36993f [zsxwing] Update the return type to JavaRDD[T]
71df047 [zsxwing] Add emptyRDD to pyspark and fix the issue when calling sum on an empty RDD
Diffstat (limited to 'python/pyspark/tests.py')
-rw-r--r-- | python/pyspark/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py index f9fb37f7fc..11b402e6df 100644 --- a/python/pyspark/tests.py +++ b/python/pyspark/tests.py @@ -458,6 +458,14 @@ class RDDTests(ReusedPySparkTestCase): self.assertEqual(id + 1, id2) self.assertEqual(id2, rdd2.id()) + def test_empty_rdd(self): + rdd = self.sc.emptyRDD() + self.assertTrue(rdd.isEmpty()) + + def test_sum(self): + self.assertEqual(0, self.sc.emptyRDD().sum()) + self.assertEqual(6, self.sc.parallelize([1, 2, 3]).sum()) + def test_save_as_textfile_with_unicode(self): # Regression test for SPARK-970 x = u"\u00A1Hola, mundo!" |