wangyum commented on code in PR #40115:
URL: https://github.com/apache/spark/pull/40115#discussion_r1115111006
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala:
##########
@@ -3592,6 +3592,34 @@ class DataFrameSuite extends QueryTest
val df = Seq("0.5944910").toDF("a")
checkAnswer(df.selectExpr("cast(a as decimal(7,7)) div 100"), Row(0))
}
+
+ test("SPARK-42525: collapse two adjacent windows with the same
partition/order in subquery") {
Review Comment:
This is because their qualifiers are different. Please add a test to
`CollapseWindowSuite`:
```scala
val query = testRelation
.window(Seq(min(a).as("_we0")), Seq(c.withQualifier(Seq("0"))), Seq(c.asc))
.select($"a", $"b", $"c", $"_we0" as "min_a")
.window(Seq(max(a).as("_we1")), Seq(c.withQualifier(Seq("1"))), Seq(c.asc))
.select($"a", $"b", $"c", $"min_a", $"_we1" as "max_a")
.analyze
val optimized = Optimize.execute(query)
val correctAnswer = testRelation
.window(Seq(min(a).as("_we0"), max(a).as("_we1")), Seq(c), Seq(c.asc))
.select(a, b, c, $"_we0" as "min_a", $"_we1" as "max_a")
.analyze
comparePlans(optimized, correctAnswer)
```
--
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]