allisonwang-db commented on a change in pull request #32787:
URL: https://github.com/apache/spark/pull/32787#discussion_r660149328



##########
File path: sql/core/src/test/resources/sql-tests/results/join-lateral.sql.out
##########
@@ -80,6 +80,46 @@ struct<c1:int,c2:int,c1:int,c2:int>
 1      2       0       3
 
 
+-- !query
+SELECT * FROM t1, LATERAL (SELECT t1.*)
+-- !query schema
+struct<c1:int,c2:int,c1:int,c2:int>
+-- !query output
+0      1       0       1
+1      2       1       2
+
+
+-- !query
+SELECT * FROM t1, LATERAL (SELECT t1.*, t2.* FROM t2)
+-- !query schema
+struct<c1:int,c2:int,c1:int,c2:int,c1:int,c2:int>
+-- !query output
+0      1       0       1       0       2
+0      1       0       1       0       3
+1      2       1       2       0       2
+1      2       1       2       0       3
+
+
+-- !query
+SELECT * FROM t1, LATERAL (SELECT t1.* FROM t2 AS t1)
+-- !query schema
+struct<c1:int,c2:int,c1:int,c2:int>
+-- !query output
+0      1       0       2
+0      1       0       3
+1      2       0       2
+1      2       0       3
+
+
+-- !query
+SELECT * FROM t1, LATERAL (SELECT t1.*, t2.* FROM t2, LATERAL (SELECT t1.*, 
t2.*, t3.* FROM t2 AS t3))

Review comment:
       Good question. Current Spark can only resolve the subquery using the 
immediate outer query. In this case t1.* can only be resolved using output from 
t2, which is c1, c2. There are many other places need to be updated to support 
nested subqueries with deep correlations.
   
https://github.com/apache/spark/blob/9c157a490bb59e02dcf44b14b411ea5beb68c238/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/subquery.scala#L164-L173




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to