beliefer commented on code in PR #46226:
URL: https://github.com/apache/spark/pull/46226#discussion_r1580336994
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFramesSuite.scala:
##########
@@ -32,6 +32,28 @@ import org.apache.spark.sql.types.CalendarIntervalType
class DataFrameWindowFramesSuite extends QueryTest with SharedSparkSession {
import testImplicits._
+ test("reuse window partitionBy") {
+ val df = Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", "value")
+ val w = Window.partitionBy("key").orderBy("value")
+
+ checkAnswer(
+ df.select(
+ lead("key", 1).over(w),
+ lead("value", 1).over(w)),
+ Row(1, "1") :: Row(2, "2") :: Row(null, null) :: Row(null, null) :: Nil)
+ }
+
+ test("reuse window orderBy") {
+ val df = Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", "value")
+ val w = Window.orderBy("value").partitionBy("key")
+
+ checkAnswer(
+ df.select(
+ lead("key", 1).over(w),
+ lead("value", 1).over(w)),
Review Comment:
This test case used to test the order by for window can be reused. We can
change lead to other window function.
--
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]