francis0407 commented on a change in pull request #23783: [SPARK-26854][SQL] 
Support ANY/SOME subquery
URL: https://github.com/apache/spark/pull/23783#discussion_r256768365
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/SubquerySuite.scala
 ##########
 @@ -1316,4 +1316,40 @@ class SubquerySuite extends QueryTest with 
SharedSQLContext {
       checkAnswer(df3, Seq(Row("a", 2, "a"), Row("a", 2, "b")))
     }
   }
+
+  test("SPARK-26854: support ANY subquery") {
+
+    checkAnswer(
+      sql(
+        """
+          |SELECT a, b
+          |FROM l
+          |WHERE a > ANY (SELECT c
+          |               FROM r)
+        """.stripMargin
+      ),
+      Row(3, 3.0)::Row(6, null)::Nil
+    )
+
+    val df_any = sql(
+      """
+        |SELECT a, b
+        |FROM l
+        |WHERE a = ANY (SELECT c
+        |               FROM r)
+      """.stripMargin
+    )
+    val df_in = sql(
+      """
+        |SELECT a, b
+        |FROM l
+        |WHERE a IN (SELECT c
+        |            FROM r)
+      """.stripMargin
+    )
+    checkAnswer(df_any, Row(2, 1.0)::Row(2, 1.0)::Row(3, 3.0)::Row(6, 
null)::Nil)
+
+    // `IN` should be equivalent to `= ANY`.
+    checkAnswer(df_any, df_in)
+  }
 
 Review comment:
   ok

----------------------------------------------------------------
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