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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala
##########
@@ -168,6 +168,21 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with 
PredicateHelper {
   }
 }
 
+/**
+ * Rewrite lateral joins by rewriting all dependent joins (if any) inside the 
right
+ * sub-tree of the lateral join and converting the lateral join into a base 
join type.
+ */
+object RewriteLateralJoin extends Rule[LogicalPlan] with PredicateHelper {
+
+  def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {
+    case j @ Join(left, right, LateralJoin(joinType), condition, _) =>
+      val conditions = condition.map(splitConjunctivePredicates).getOrElse(Nil)
+      val newRight = DecorrelateInnerQuery.rewriteDomainJoins(left, right, 
conditions)
+      // TODO: handle the COUNT bug

Review comment:
       Created a new ticket for handling the COUNT bug in lateral subqueries: 
https://issues.apache.org/jira/browse/SPARK-35551




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

Reply via email to