Github user zhengruifeng commented on a diff in the pull request:
https://github.com/apache/spark/pull/16971#discussion_r102167055
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala ---
@@ -214,20 +214,29 @@ class DataFrameStatSuite extends QueryTest with
SharedSQLContext {
val q1 = 0.5
val q2 = 0.8
val epsilon = 0.1
- val rows = spark.sparkContext.parallelize(Seq(Row(Double.NaN, 1.0),
Row(1.0, 1.0),
+ val rows = spark.sparkContext.parallelize(Seq(Row(Double.NaN, 1.0),
Row(1.0, -1.0),
Row(-1.0, Double.NaN), Row(Double.NaN, Double.NaN), Row(null, null),
Row(null, 1.0),
Row(-1.0, null), Row(Double.NaN, null)))
val schema = StructType(Seq(StructField("input1", DoubleType, nullable
= true),
StructField("input2", DoubleType, nullable = true)))
val dfNaN = spark.createDataFrame(rows, schema)
- val resNaN = dfNaN.stat.approxQuantile("input1", Array(q1, q2),
epsilon)
- assert(resNaN.count(_.isNaN) === 0)
- assert(resNaN.count(_ == null) === 0)
+ val resNaN1 = dfNaN.stat.approxQuantile("input1", Array(q1, q2),
epsilon)
+ assert(resNaN1.count(_.isNaN) === 0)
+ assert(resNaN1.count(_ == null) === 0)
- val resNaN2 = dfNaN.stat.approxQuantile(Array("input1", "input2"),
+ val resNaN2 = dfNaN.stat.approxQuantile("input2", Array(q1, q2),
epsilon)
+ assert(resNaN2.count(_.isNaN) === 0)
+ assert(resNaN2.count(_ == null) === 0)
+
+ val resNaNAll = dfNaN.stat.approxQuantile(Array("input1", "input2"),
Array(q1, q2), epsilon)
- assert(resNaN2.flatten.count(_.isNaN) === 0)
- assert(resNaN2.flatten.count(_ == null) === 0)
+ assert(resNaNAll.flatten.count(_.isNaN) === 0)
+ assert(resNaNAll.flatten.count(_ == null) === 0)
+
+ assert(resNaN1(0) === resNaNAll(0)(0))
+ assert(resNaN1(1) === resNaNAll(0)(1))
+ assert(resNaN2(0) === resNaNAll(1)(0))
+ assert(resNaN2(1) === resNaNAll(1)(1))
--- End diff --
Yes, I create a new column containing only NaN/null.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]