From e986c65f4e968bf58d16569055eda13414f5ec33 Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Tue, 14 Jul 2020 17:51:08 +0900 Subject: [PATCH] toPandas should work from a Spark DataFrame with no partitions --- python/pyspark/sql/tests/test_arrow.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/pyspark/sql/tests/test_arrow.py b/python/pyspark/sql/tests/test_arrow.py index 90fc983aec021..148df9b7d45b8 100644 --- a/python/pyspark/sql/tests/test_arrow.py +++ b/python/pyspark/sql/tests/test_arrow.py @@ -447,6 +447,13 @@ def test_createDataFrame_with_float_index(self): self.spark.createDataFrame( pd.DataFrame({'a': [1, 2, 3]}, index=[2., 3., 4.])).distinct().count(), 3) + def test_no_partition_toPandas(self): + # SPARK-32301: toPandas should work from a Spark DataFrame with no partitions + # Forward-ported from SPARK-32300. + pdf = self.spark.sparkContext.emptyRDD().toDF("col1 int").toPandas() + self.assertEqual(len(pdf), 0) + self.assertEqual(list(pdf.columns), ["col1"]) + @unittest.skipIf( not have_pandas or not have_pyarrow,