i7xh commented on a change in pull request #1129:
URL: https://github.com/apache/incubator-kyuubi/pull/1129#discussion_r724681411



##########
File path: 
dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsRule.scala
##########
@@ -70,3 +92,29 @@ 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)
+    )
+  }
+
+  override def apply(plan: LogicalPlan): LogicalPlan = plan match {
+
+    case a: Aggregate if a.aggregateExpressions
+      .exists(x => x.resolved && x.name.equals("aggOrder")) => 
markChildAggregate(a)

Review comment:
       > Can we add some comment why we only need check `aggOrder` if top level 
node is `Aggregate` and not need check it with children ?
   
   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
   ```




-- 
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]


Reply via email to