WeichenXu123 commented on a change in pull request #25512: [SPARK-28782][SQL]
Generator support in aggregate expressions
URL: https://github.com/apache/spark/pull/25512#discussion_r320235274
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -2018,6 +2018,62 @@ class Analyzer(
throw new AnalysisException("Only one generator allowed per select
clause but found " +
generators.size + ": " + generators.map(toPrettySQL).mkString(", "))
+ case Aggregate(_, aggList, _) if aggList.exists(hasNestedGenerator) =>
+ val nestedGenerator = aggList.find(hasNestedGenerator).get
+ throw new AnalysisException("Generators are not supported when it's
nested in " +
+ "expressions, but got: " + toPrettySQL(trimAlias(nestedGenerator)))
+
+ case Aggregate(_, aggList, _) if aggList.count(hasGenerator) > 1 =>
+ val generators = aggList.filter(hasGenerator).map(trimAlias)
+ throw new AnalysisException("Only one generator allowed per aggregate
clause but found " +
+ generators.size + ": " + generators.map(toPrettySQL).mkString(", "))
+
+ case agg @ Aggregate(groupList, aggList, child) if aggList.forall {
+ case AliasedGenerator(generator, _, _) => generator.childrenResolved
Review comment:
Ah you are right, `Generator` instance is resolved, but the structure
`Alias(GeneratorOuter(generator)`, the `Alias` node and `GeneratorOuter` node
is unresolved.
So we still cannot use the judgment `if aggList.forall(_.resolved)`.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]