cloud-fan 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_r320089158
##########
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:
please take a look at the object `AliasedGenerator`. There is no
`AliasedGenerator` instance. It's just an `unapply` method. And we can use
`hasGenerator` here.
----------------------------------------------------------------
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]