Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 41f633d

Browse files
committed
Failed test case.
1 parent 90c6069 commit 41f633d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,42 @@ class SQLQuerySuite extends QueryTest {
780780
).map(i => Row(i._1, i._2, i._3, i._4)))
781781
}
782782

783+
test("window function: multiple window expressions in a single expression") {
784+
val nums = sparkContext.parallelize(1 to 10).map(x => (x, x % 2)).toDF("x", "y")
785+
nums.registerTempTable("nums")
786+
787+
val expected =
788+
Row(1, 1, 1, 55, 1, 57) ::
789+
Row(0, 2, 3, 55, 2, 60) ::
790+
Row(1, 3, 6, 55, 4, 65) ::
791+
Row(0, 4, 10, 55, 6, 71) ::
792+
Row(1, 5, 15, 55, 9, 79) ::
793+
Row(0, 6, 21, 55, 12, 88) ::
794+
Row(1, 7, 28, 55, 16, 99) ::
795+
Row(0, 8, 36, 55, 20, 111) ::
796+
Row(1, 9, 45, 55, 25, 125) ::
797+
Row(0, 10, 55, 55, 30, 140) :: Nil
798+
799+
val actual = sql(
800+
"""
801+
|SELECT
802+
| y,
803+
| x,
804+
| sum(x) OVER w1 AS running_sum,
805+
| sum(x) OVER w2 AS total_sum,
806+
| sum(x) OVER w3 AS running_sum_per_y,
807+
| ((sum(x) OVER w1) + (sum(x) OVER w2) + (sum(x) OVER w3)) as combined2
808+
|FROM nums
809+
|WINDOW w1 AS (ORDER BY x ROWS BETWEEN UnBOUNDED PRECEDiNG AND CuRRENT RoW),
810+
| w2 AS (ORDER BY x ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOuNDED FoLLOWING),
811+
| w3 AS (PARTITION BY y ORDER BY x ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
812+
""".stripMargin)
813+
814+
checkAnswer(actual, expected)
815+
816+
dropTempTable("nums")
817+
}
818+
783819
test("test case key when") {
784820
(1 to 5).map(i => (i, i.toString)).toDF("k", "v").registerTempTable("t")
785821
checkAnswer(

0 commit comments

Comments
 (0)