allisonwang-db commented on a change in pull request #32303:
URL: https://github.com/apache/spark/pull/32303#discussion_r619415048
##########
File path: sql/core/src/test/resources/sql-tests/inputs/join-lateral.sql
##########
@@ -0,0 +1,84 @@
+-- Test cases for lateral join
+
+CREATE VIEW t1(c1, c2) AS VALUES (0, 1), (1, 2);
+CREATE VIEW t2(c1, c2) AS VALUES (0, 2), (0, 3);
+
+-- lateral join with single column select
+SELECT * FROM t1, LATERAL (SELECT c1);
Review comment:
> Is this compiled into a join query? We cannot compile it into a simple
scan query like PostgreSQL?
>
> ```
> postgres=# explain SELECT * FROM t1, LATERAL (SELECT c1) t2;
> QUERY PLAN
> --------------------------------------------------------------
> Values Scan on "*VALUES*" (cost=0.00..0.03 rows=2 width=12)
> (1 row)
> ```
Yes it should be rewritten as a simple scan query`SELECT c1 FROM t1` instead
of a join query. I am thinking about adding an optimizer rule for
OneRowRelation. This can be applied to correlated subqueries as well.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]