ulysses-you commented on a change in pull request #1129:
URL: https://github.com/apache/incubator-kyuubi/pull/1129#discussion_r725423543
##########
File path:
dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsRule.scala
##########
@@ -70,3 +89,41 @@ case class ForcedMaxOutputRowsRule(session: SparkSession)
extends Rule[LogicalPl
}
}
+
+case class MarkAggregateOrderRule(session: SparkSession) extends
Rule[LogicalPlan] {
+
+ private def markChildAggregate(a: Aggregate): Unit = {
+ // mark child aggregate
+ a.aggregateExpressions.filter(_.resolved).foreach(_.setTagValue(
+ ForcedMaxOutputRowsConstraint.CHILD_AGGREGATE,
+ ForcedMaxOutputRowsConstraint.CHILD_AGGREGATE_FLAG)
+ )
+ }
+
+ private def findAndMarkChildAggregate(plan: LogicalPlan): LogicalPlan = plan
match {
+ /*
+ * The case mainly process order not aggregate column but grouping column
as below
+ * SELECT c1, COUNT(*) as cnt
+ * FROM t1
+ * GROUP BY c1
+ * ORDER BY c1
+ * */
+ case a: Aggregate if a.aggregateExpressions
+ .exists(x => x.resolved && x.name.equals("aggOrder")) =>
markChildAggregate(a)
+ plan
+
+ case _ => plan.children.foreach { c =>
+ c.foreach {
+ case agg: Aggregate => markChildAggregate(agg)
+ case _ => Unit}
+ }
Review comment:
```scala
plan.children.foreach {
case agg: Aggregate => markChildAggregate(agg)
case _ =>
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]