From 6afab77174cbf7b519c568e127b9c11c1fa62e16 Mon Sep 17 00:00:00 2001 From: wforget <643348094@qq.com> Date: Tue, 12 Mar 2024 15:59:49 +0800 Subject: [PATCH] [KYUUBI #6168] Check if forcedMaxOutputRows is negative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # :mag: Description ## Issue References ๐Ÿ”— This pull request fixes #6168 ## Describe Your Solution ๐Ÿ”ง Check if forcedMaxOutputRows is negative. ## Types of changes :bookmark: - [X] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan ๐Ÿงช #### Behavior Without This Pull Request :coffin: #### Behavior With This Pull Request :tada: #### Related Unit Tests --- # Checklist ๐Ÿ“ - [X] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6169 from wForget/KYUUBI-6168. Closes #6168 b18d8e5f5 [wforget] fix style 057c5388b [wforget] Check if forcedMaxOutputRows is negative Authored-by: wforget <643348094@qq.com> Signed-off-by: Cheng Pan (cherry picked from commit 6a4f6f0c88938633efb4454df9297e7ede26da57) --- .../kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala | 6 +++--- .../kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala | 6 +++--- .../kyuubi/sql/watchdog/ForcedMaxOutputRowsBase.scala | 6 +++--- 3 files changed, 9 insertions(+), 9 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..dd329bd659e 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) && - !p.maxRows.exists(_ <= forcedMaxOutputRows) - case None => false + case Some(forcedMaxOutputRows) if forcedMaxOutputRows >= 0 => + canInsertLimitInner(p) && !p.maxRows.exists(_ <= forcedMaxOutputRows) + 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..dd329bd659e 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) && - !p.maxRows.exists(_ <= forcedMaxOutputRows) - case None => false + case Some(forcedMaxOutputRows) if forcedMaxOutputRows >= 0 => + canInsertLimitInner(p) && !p.maxRows.exists(_ <= forcedMaxOutputRows) + 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..dd329bd659e 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) && - !p.maxRows.exists(_ <= forcedMaxOutputRows) - case None => false + case Some(forcedMaxOutputRows) if forcedMaxOutputRows >= 0 => + canInsertLimitInner(p) && !p.maxRows.exists(_ <= forcedMaxOutputRows) + case _ => false } }