peter-toth commented on a change in pull request #23531: [SPARK-24497][SQL] 
Support recursive SQL query
URL: https://github.com/apache/spark/pull/23531#discussion_r252286309
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ##########
 @@ -202,19 +203,58 @@ class Analyzer(
     Batch("Subquery", Once,
       UpdateOuterReferences),
     Batch("Cleanup", fixedPoint,
-      CleanupAliases)
+      CleanupAliases),
+    Batch("Recursion", Once,
+      CheckRecursionConstraints)
   )
 
+  object ResolveRecursiveReferneces extends Rule[LogicalPlan] {
 
 Review comment:
   I remember now. The thing is that when we have nested recursion and the 
outer recursive reference is in the anchor of the inner recursion like this:
   ```
   -- recursion nested into recursion 2
   WITH RECURSIVE t AS (
     WITH RECURSIVE s AS (
       SELECT j, 1 AS i FROM t
       UNION ALL
       SELECT j, i + 1 FROM s WHERE i < 3
     )
     VALUES (1) as t(j)
     UNION ALL
     SELECT j + 1 FROM s WHERE j < 3
   )
   SELECT * FROM t;
   ```
   analyzing the inner will not resolve it's anchor and so we can't place 
resolved `RecursiveReference s` immediately into the plan.

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