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_r261900867
 
 

 ##########
 File path: 
sql/core/src/test/resources/sql-tests/inputs/subquery/any-subquery/simple-any.sql
 ##########
 @@ -0,0 +1,96 @@
+-- A test suite for ANY/SOME predicate subquery
+
+CREATE TEMPORARY VIEW a AS SELECT * FROM VALUES
+  (1, 1),
+  (null, 2),
+  (3, 3),
+  (4, 4)
+  AS a(a1, a2);
+
+CREATE TEMPORARY VIEW b AS SELECT * FROM VALUES
+  (3, 1),
+  (null, 2)
+  AS b(b1, b2);
+
+CREATE TEMPORARY VIEW c AS SELECT * FROM VALUES
+  (null, 1)
+  AS c(c1, c2);
+
+-- comparison operators
+-- TC 01.01
+SELECT *
+FROM   a
+WHERE  a1 > ANY (SELECT b1
+                 FROM   b );
+
+-- TC 01.02
+SELECT *
+FROM   a
+WHERE  a1 >= ANY (SELECT b1
+                  FROM   b );
+
+-- TC 01.03
+SELECT *
+FROM   a
+WHERE  a1 < ANY (SELECT b1
+                 FROM   b );
+
+-- TC 01.04
+SELECT *
+FROM   a
+WHERE  a1 <= ANY (SELECT b1
+                  FROM   b );
+
+-- TC 01.05
+SELECT *
+FROM   a
+WHERE  a1 != ANY (SELECT b1
+                  FROM   b );
+
+-- TC 01.06
+SELECT *
+FROM   a
+WHERE  a1 = ANY (SELECT b1
+                 FROM   b );
+
+-- TC 01.07
+SELECT *
+FROM   a
+WHERE  a1 <=> ANY (SELECT b1
+                   FROM   b );
+
+-- compare with `null`
+-- TC 02.01
+SELECT *
+FROM   a
+WHERE  a1 > ANY (SELECT c1
+                 FROM   c );
+
+-- TC 02.02
+SELECT *
+FROM   a
+WHERE  a1 != ANY (SELECT c1
+                  FROM   c );
+
+-- TC 02.03
+SELECT *
 
 Review comment:
   I aimed to show how nulls exactly work. Maybe it would be better to design 
'b' as '(3, 1), (4, 2)' and 'c' as '(3, 1), (4, 2), (null, 3)'.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to