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_r248416130
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1530,6 +1650,18 @@ class Analyzer(
object GlobalAggregates extends Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
case Project(projectList, child) if containsAggregates(projectList) =>
+
+ def traversePlanAndCheck(plan: LogicalPlan): Unit =
Review comment:
I can't move this check to `CTESubstitution` because the time when it runs
aggregate functions haven't been resolved yet and `containsAggregates()`
doesn't work.
btw we need this in this case:
```
-- recursive reference is not allowed in an aggregate (made from project) in
a recursive term
WITH RECURSIVE r AS (
VALUES (1L) AS T(data)
UNION ALL
SELECT SUM(data) FROM r WHERE data < 10
)
SELECT * FROM r;
```
when there is a projection only in the beginning and then that projection is
then transformed to an aggregate in 'GlobalAggregates', that's why I thought
this would be a good place to do the test.
Do you think moving this one check to a dedicated "checker" rule is better?
----------------------------------------------------------------
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]