Skip to content

Commit 307ecbf

Browse files
committed
Add failing regression test for SPARK-7687
1 parent 0b6f503 commit 307ecbf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

python/pyspark/sql/dataframe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,11 @@ def describe(self, *cols):
599599
+-------+---+
600600
|summary|age|
601601
+-------+---+
602-
| count| 2|
602+
| count|2.0|
603603
| mean|3.5|
604604
| stddev|1.5|
605-
| min| 2|
606-
| max| 5|
605+
| min|2.0|
606+
| max|5.0|
607607
+-------+---+
608608
"""
609609
jdf = self._jdf.describe(self._jseq(cols))

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ class DataFrameSuite extends QueryTest {
388388
val describeTwoCols = describeTestData.describe("age", "height")
389389
assert(getSchemaAsSeq(describeTwoCols) === Seq("summary", "age", "height"))
390390
checkAnswer(describeTwoCols, describeResult)
391+
// All aggregate value should have been cast to double, including `count`
392+
describeTwoCols.collect().foreach { row =>
393+
assert(row.get(1).isInstanceOf[Double], "expected double but found " + row.get(1).getClass)
394+
assert(row.get(2).isInstanceOf[Double], "expected double but found " + row.get(2).getClass)
395+
}
391396

392397
val describeAllCols = describeTestData.describe()
393398
assert(getSchemaAsSeq(describeAllCols) === Seq("summary", "age", "height"))

0 commit comments

Comments
 (0)