ulysses-you commented on code in PR #57602:
URL: https://github.com/apache/spark/pull/57602#discussion_r3687497306


##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFunctionsSuite.scala:
##########
@@ -1682,6 +1682,39 @@ class DataFrameWindowFunctionsSuite extends 
SharedSparkSession
     }
   }
 
+  test("SPARK-58404: bypass partial WindowGroupLimit") {
+    val df = Seq(
+      ("a", 0, "c"),
+      ("a", 1, "x"),
+      ("a", 2, "y"),
+      ("b", 1, "h"),
+      ("b", 1, "n"),
+      ("c", 1, "z"),
+      ("c", 2, "a")).toDF("key", "value", "order")
+
+    val window = Window.partitionBy($"key").orderBy($"order")
+    val expected = Seq(
+      Row("a", 0, "c", 1),
+      Row("b", 1, "h", 1),
+      Row("c", 2, "a", 1))
+
+    Seq(true, false).foreach { bypass =>
+      withSQLConf(
+        SQLConf.BYPASS_PARTIAL_WINDOW_GROUP_LIMIT.key -> bypass.toString,
+        SQLConf.WINDOW_GROUP_LIMIT_THRESHOLD.key -> "100") {
+        val result = df.withColumn("rn", 
row_number().over(window)).where($"rn" === 1)
+        checkAnswer(result, expected)
+
+        val limits = collect(result.queryExecution.executedPlan) {
+          case w: WindowGroupLimitExec => w
+        }
+        // When bypassed, only the final WindowGroupLimit remains; otherwise 
both partial and
+        // final are present since a shuffle is required.
+        assert(limits.size === (if (bypass) 1 else 2))
+      }
+    }
+  }

Review Comment:
   thank you @peter-toth , I'm fine to only apply on non-empty partitionSpec to 
align with agg side. 



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


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

Reply via email to