From 7ef2c6551bfabf50e8684c6c7a54b2b0266796a9 Mon Sep 17 00:00:00 2001 From: lsy3993 Date: Thu, 15 Sep 2022 16:24:56 +0800 Subject: [PATCH] add cte test in regression of window function --- .../window_functions/test_window_fn.out | 39 +++++++++++++++++++ .../window_functions/test_window_fn.groovy | 16 ++++++++ 2 files changed, 55 insertions(+) diff --git a/regression-test/data/query_p0/sql_functions/window_functions/test_window_fn.out b/regression-test/data/query_p0/sql_functions/window_functions/test_window_fn.out index b3a92b1adeebf9..06b1d657cda026 100644 --- a/regression-test/data/query_p0/sql_functions/window_functions/test_window_fn.out +++ b/regression-test/data/query_p0/sql_functions/window_functions/test_window_fn.out @@ -586,3 +586,42 @@ sales 4 4800 14600 -- !sql -- +-- !sql -- +1 60 +2 60 +3 60 +4 60 +5 60 +7 60 +8 60 +9 60 +10 60 +11 60 + +-- !sql -- +1 1 +2 3 +3 6 +4 10 +5 15 +7 22 +8 30 +9 39 +10 49 +11 60 + +-- !sql -- +1 2 +1 3 +1 3 +1 4 +2 6 +3 9 +4 12 +5 16 +7 20 +8 24 +9 27 +10 30 +11 21 + diff --git a/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy b/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy index fd29beac1572f1..1db5041cc75330 100644 --- a/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy +++ b/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy @@ -302,6 +302,22 @@ suite("test_window_fn") { WHERE total <> fourcount + twosum; """ + // cte + qt_sql """ + with cte as (select empno as x from ${tbName1}) + SELECT x, (sum(x) over (ORDER BY x range between UNBOUNDED preceding and UNBOUNDED following)) FROM cte; + """ + qt_sql """ + with cte as (select empno as x from ${tbName1}) + SELECT x, (sum(x) over (ORDER BY x range between UNBOUNDED preceding and CURRENT ROW)) FROM cte; + """ + qt_sql """ + WITH cte AS ( + select 1 as x union all select 1 as x union all select 1 as x union all + SELECT empno as x FROM ${tbName1}) + SELECT x, (sum(x) over (ORDER BY x rows between 1 preceding and 1 following)) FROM cte; + """ + sql "DROP TABLE IF EXISTS ${tbName1};" sql "DROP TABLE IF EXISTS ${tbName2};" }