cloud-fan commented on a change in pull request #26738: [SPARK-30082][SQL] Do 
not replace Zeros when replacing NaNs
URL: https://github.com/apache/spark/pull/26738#discussion_r353164427
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/DataFrameNaFunctionsSuite.scala
 ##########
 @@ -404,4 +412,48 @@ class DataFrameNaFunctionsSuite extends QueryTest with 
SharedSparkSession {
       df.na.drop("any"),
       Row("5", "6", "6") :: Nil)
   }
+
+  test("replace nan with float") {
+    checkAnswer(
+      createNaNDF().na.replace("*", Map(
+        Float.NaN -> 10f
+      )),
+      Row(1, new java.lang.Long(1), new java.lang.Short("1"),
+        new java.lang.Byte("1"), new java.lang.Float(1.0), 1.0) ::
+      Row(0, new java.lang.Long(0), new java.lang.Short("0"),
+        new java.lang.Byte("0"), new java.lang.Float(10), new 
java.lang.Double(10)) :: Nil)
+  }
+
+  test("replace nan with double") {
+    checkAnswer(
+      createNaNDF().na.replace("*", Map(
+        Double.NaN -> 10.toDouble
+      )),
+      Row(1, new java.lang.Long(1), new java.lang.Short("1"),
 
 Review comment:
   ditto

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to