This is an automated email from the ASF dual-hosted git repository.

hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 22bb0b393 [GLUTEN-7090][VL] fix: Number of sorting keys must be 
greater than zero (#7089)
22bb0b393 is described below

commit 22bb0b39368ff074b9dc66685fb83dc779343f94
Author: Qian Sun <[email protected]>
AuthorDate: Tue Sep 3 16:23:49 2024 +0800

    [GLUTEN-7090][VL] fix: Number of sorting keys must be greater than zero 
(#7089)
    
    Closes #7090
---
 .../gluten/execution/VeloxWindowExpressionSuite.scala      | 14 ++++++++++++++
 cpp/velox/substrait/SubstraitToVeloxPlan.cc                |  8 ++++++++
 2 files changed, 22 insertions(+)

diff --git 
a/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxWindowExpressionSuite.scala
 
b/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxWindowExpressionSuite.scala
index 03b295f49..7af17c4cd 100644
--- 
a/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxWindowExpressionSuite.scala
+++ 
b/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxWindowExpressionSuite.scala
@@ -73,6 +73,20 @@ class VeloxWindowExpressionSuite extends 
WholeStageTransformerSuite {
     }
   }
 
+  test("test overlapping partition and sorting keys") {
+    runAndCompare(
+      """
+        |WITH t AS (
+        |SELECT
+        | l_linenumber,
+        | row_number() over (partition by l_linenumber order by l_linenumber) 
as rn
+        |FROM lineitem
+        |)
+        |SELECT * FROM t WHERE rn = 1
+        |""".stripMargin
+    ) {}
+  }
+
   test("collect_list / collect_set") {
     withTable("t") {
       val data = Seq(
diff --git a/cpp/velox/substrait/SubstraitToVeloxPlan.cc 
b/cpp/velox/substrait/SubstraitToVeloxPlan.cc
index 1604c15e3..bd545a960 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlan.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxPlan.cc
@@ -1024,6 +1024,14 @@ core::PlanNodePtr 
SubstraitToVeloxPlanConverter::toVeloxPlan(
     }
   }
   const std::optional<std::string> rowNumberColumnName = std::nullopt;
+
+  if (sortingKeys.empty()) {
+    // Handle if all sorting keys are also used as partition keys.
+
+    return std::make_shared<core::RowNumberNode>(
+        nextPlanNodeId(), partitionKeys, rowNumberColumnName, 
(int32_t)windowGroupLimitRel.limit(), childNode);
+  }
+
   return std::make_shared<core::TopNRowNumberNode>(
       nextPlanNodeId(),
       partitionKeys,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to