From 057c5388bde5ca15102b8e24be8a09bf073f0291 Mon Sep 17 00:00:00 2001 From: wforget <643348094@qq.com> Date: Tue, 12 Mar 2024 11:53:37 +0800 Subject: [PATCH] Check if forcedMaxOutputRows is negative --- .../apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala | 4 ++-- .../apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala | 4 ++-- .../apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/spark/kyuubi-extension-spark-3-4/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala b/extensions/spark/kyuubi-extension-spark-3-4/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala index 4f897d1b600..015632b147f 100644 --- a/extensions/spark/kyuubi-extension-spark-3-4/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala +++ b/extensions/spark/kyuubi-extension-spark-3-4/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala @@ -71,9 +71,9 @@ trait ForcedMaxOutputRowsBase extends Rule[LogicalPlan] { protected def canInsertLimit(p: LogicalPlan, maxOutputRowsOpt: Option[Int]): Boolean = { maxOutputRowsOpt match { - case Some(forcedMaxOutputRows) => canInsertLimitInner(p) && + case Some(forcedMaxOutputRows) if forcedMaxOutputRows >= 0 => canInsertLimitInner(p) && !p.maxRows.exists(_ <= forcedMaxOutputRows) - case None => false + case _ => false } } diff --git a/extensions/spark/kyuubi-extension-spark-3-5/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala b/extensions/spark/kyuubi-extension-spark-3-5/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala index 4f897d1b600..015632b147f 100644 --- a/extensions/spark/kyuubi-extension-spark-3-5/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala +++ b/extensions/spark/kyuubi-extension-spark-3-5/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala @@ -71,9 +71,9 @@ trait ForcedMaxOutputRowsBase extends Rule[LogicalPlan] { protected def canInsertLimit(p: LogicalPlan, maxOutputRowsOpt: Option[Int]): Boolean = { maxOutputRowsOpt match { - case Some(forcedMaxOutputRows) => canInsertLimitInner(p) && + case Some(forcedMaxOutputRows) if forcedMaxOutputRows >= 0 => canInsertLimitInner(p) && !p.maxRows.exists(_ <= forcedMaxOutputRows) - case None => false + case _ => false } } diff --git a/extensions/spark/kyuubi-extension-spark-common/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala b/extensions/spark/kyuubi-extension-spark-common/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala index 4f897d1b600..015632b147f 100644 --- a/extensions/spark/kyuubi-extension-spark-common/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala +++ b/extensions/spark/kyuubi-extension-spark-common/src/main/scala/org/apache/kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala @@ -71,9 +71,9 @@ trait ForcedMaxOutputRowsBase extends Rule[LogicalPlan] { protected def canInsertLimit(p: LogicalPlan, maxOutputRowsOpt: Option[Int]): Boolean = { maxOutputRowsOpt match { - case Some(forcedMaxOutputRows) => canInsertLimitInner(p) && + case Some(forcedMaxOutputRows) if forcedMaxOutputRows >= 0 => canInsertLimitInner(p) && !p.maxRows.exists(_ <= forcedMaxOutputRows) - case None => false + case _ => false } }