You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/10/07 10:48:49 UTC

[GitHub] [incubator-kyuubi] ulysses-you commented on a change in pull request #1129: [KYUUBI #1085][FOLLOWUP] Fix-Enforce maxOutputRows for aggregate with having statement

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



##########
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.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)
+      plan
+
+    case _ => plan.children.foreach { c =>
+      c.foreach {
+        case agg: Aggregate => markChildAggregate(agg)

Review comment:
       why we don't need check if aggregateExpressions is resolved 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.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org