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_r320582127
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ########## @@ -2018,6 +2018,58 @@ 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.resolved Review comment: nit: `case AliasedGenerator(_, _, _) => true`. `AliasedGenerator` guarantees the generator is 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org