bart-samwel commented on a change in pull request #23388: [SPARK-26448][SQL] 
retain the difference between 0.0 and -0.0
URL: https://github.com/apache/spark/pull/23388#discussion_r245779045
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/JoinSuite.scala
 ##########
 @@ -909,4 +909,50 @@ class JoinSuite extends QueryTest with SharedSQLContext {
       checkAnswer(df, Row(1, 100, 42, 200, 1, 42))
     }
   }
+
+  test("NaN and -0.0 in join keys") {
+    withTempView("v1", "v2", "v3", "v4") {
+      Seq(Float.NaN -> Double.NaN, 0.0f -> 0.0, -0.0f -> -0.0).toDF("f", 
"d").createTempView("v1")
+      Seq(Float.NaN -> Double.NaN, 0.0f -> 0.0, -0.0f -> -0.0).toDF("f", 
"d").createTempView("v2")
+
+      checkAnswer(
+        sql(
+          """
+            |SELECT v1.f, v1.d
+            |FROM v1 JOIN v2
+            |ON v1.f = v2.f AND v1.d = v2.d
+          """.stripMargin),
+        Seq(
+          Row(Float.NaN, Double.NaN),
+          Row(0.0f, 0.0),
+          Row(0.0f, 0.0),
+          Row(-0.0f, -0.0),
+          Row(-0.0f, -0.0)))
+
+      // test with complicated join keys.
+      checkAnswer(
+        sql(
+          """
+            |SELECT v1.f, v1.d
+            |FROM v1 JOIN v2
+            |ON array(v1.f) = array(v2.f) AND struct(v1.d) = struct(v2.d)
+          """.stripMargin),
+        Seq(
+          Row(Float.NaN, Double.NaN),
+          Row(0.0f, 0.0),
+          Row(0.0f, 0.0),
+          Row(-0.0f, -0.0),
+          Row(-0.0f, -0.0)))
+
+      // test with tables with complicated-type columns.
+      Seq(Array(-0.0f, 0.0f) -> Tuple2(-0.0d, Double.NaN)).toDF("arr", 
"stru").createTempView("v3")
+      Seq(Array(0.0f, -0.0f) -> Tuple2(0.0d, Double.NaN)).toDF("arr", 
"stru").createTempView("v4")
+      checkAnswer(
+        sql("SELECT v3.arr, v3.stru FROM v3 JOIN v4 ON v3.arr = v4.arr AND 
v3.stru = v4.stru"),
 
 Review comment:
   Why the style difference compared to the previous test cases?

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to