From ecde439a5fd4cb9f18e13190948bae009082e02f Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 15 Jun 2019 21:14:55 -0300 Subject: [PATCH 01/25] Start the port of window.sql tests from Postgrsql Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 918 + .../sql-tests/results/pgSQL/window.sql.out | 21407 ++++++++++++++++ 2 files changed, 22325 insertions(+) create mode 100644 sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql create mode 100644 sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql new file mode 100644 index 0000000000000..a0891d6fc8bee --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -0,0 +1,918 @@ +-- +-- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group +-- +-- Window Functions Testing +-- https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/window.sql + +CREATE TABLE empsalary ( + depname string, + empno integer, + salary int, + enroll_date date +) USING parquet; + +INSERT INTO empsalary VALUES +('develop', 10, 5200, '2007-08-01'), +('sales', 1, 5000, '2006-10-01'), +('personnel', 5, 3500, '2007-12-10'), +('sales', 4, 4800, '2007-08-08'), +('personnel', 2, 3900, '2006-12-23'), +('develop', 7, 4200, '2008-01-01'), +('develop', 9, 4500, '2008-01-01'), +('sales', 3, 4800, '2007-08-01'), +('develop', 8, 6000, '2006-10-01'), +('develop', 11, 5200, '2007-08-15'); + +SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname) FROM empsalary ORDER BY depname, salary; + +SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary; + +SELECT four, ten, SUM(SUM(four)) OVER (PARTITION BY four), AVG(ten) FROM tenk1 +GROUP BY four, ten ORDER BY four, ten; + +SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname); + +-- I get an error when trying `order by rank() over w`, however it works for `order by r' if column rank is renamed to r +SELECT depname, empno, salary, rank() OVER w as r FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY r; + +SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10; + +SELECT COUNT(*) OVER w FROM tenk1 WHERE unique2 < 10 WINDOW w AS (); + +SELECT four FROM tenk1 WHERE FALSE WINDOW w AS (PARTITION BY ten); + +SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10; + +SELECT rank() OVER (PARTITION BY four ORDER BY ten) AS rank_1, ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10; + +-- Spark does not accept null as input for `ntile` +-- SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; + +-- Spark fills with NULL instead of white space +SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +-- `lag` second argument must be a literal? +-- SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +-- SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +-- last_value returns the last row of the frame, which is CURRENT ROW in ORDER BY window. +SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +SELECT last_value(ten) OVER (PARTITION BY four), ten, four FROM +(SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s +ORDER BY four, ten; + +-- nth_value does not exist? +-- SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four +-- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s; + +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER (PARTITION BY two ORDER BY ten) AS wsum +FROM tenk1 GROUP BY ten, two; + +SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10; + +-- Original PSQL query: +-- SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + +-- sum(hundred) OVER (PARTITION BY four ORDER BY ten))::varchar AS cntsum +-- FROM tenk1 WHERE unique2 < 10; +SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY four ORDER BY ten)) AS cntsum + FROM tenk1 WHERE unique2 < 10; + +-- opexpr with different windows evaluation. +SELECT * FROM( + SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, + count(*) OVER (PARTITION BY four ORDER BY ten) AS fourcount, + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS twosum + FROM tenk1 +)sub WHERE total <> fourcount + twosum; + +SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10; + +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER win AS wsum +FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten); + +-- more than one window with GROUP BY +SELECT sum(salary), +row_number() OVER (ORDER BY depname), +sum(sum(salary)) OVER (ORDER BY depname DESC) +FROM empsalary GROUP BY depname; + +-- identical windows with different names +SELECT sum(salary) OVER w1, count(*) OVER w2 +FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); + +-- subplan/broken +-- SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) +-- FROM tenk1 s WHERE unique2 < 10; + +-- empty table +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s; + +-- mixture of agg/wfunc in the same window +SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC); + +-- strict aggs +SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( + SELECT *, + CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus, + CASE WHEN + AVG(salary) OVER (PARTITION BY depname) < salary + THEN 200 END AS depadj FROM empsalary + )s; + +create temporary view int4_tbl as select * from values + (0), + (123456), + (-123456), + (2147483647), + (-2147483647) + as int4_tbl(f1); +-- window function over ungrouped agg over empty row set +SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42; + +-- window function with ORDER BY an expression involving aggregates (9.1 bug) +select ten, + sum(unique1) + sum(unique2) as res, + rank() over (order by sum(unique1) + sum(unique2)) as rank +from tenk1 +group by ten order by ten; + +-- no costs_off? +-- explain (costs off) +-- select first_value(max(x)) over (), y +-- from (select unique1 as x, ten+four as y from tenk1) ss +-- group by y; + +-- test non-default frame specifications +SELECT four, ten, +sum(ten) over (partition by four order by ten), +last_value(ten) over (partition by four order by ten) +FROM (select distinct ten, four from tenk1) ss; + +SELECT four, ten, +sum(ten) over (partition by four order by ten range between unbounded preceding and current row), +last_value(ten) over (partition by four order by ten range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss; + +SELECT four, ten, +sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following), +last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) +FROM (select distinct ten, four from tenk1) ss; + +SELECT four, ten/4 as two, +sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row), +last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss; + +SELECT four, ten/4 as two, +sum(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row), +last_value(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss; + +SELECT sum(unique1) over (order by four range between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10; + +SELECT sum(unique1) over (rows between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10; + +SELECT sum(unique1) over (rows between 2 preceding and 2 following), +unique1, four +FROM tenk1 WHERE unique1 < 10; + +-- broken +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; + +-- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (rows between 1 following and 3 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (rows between unbounded preceding and 1 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- -- broken +-- -- SELECT sum(unique1) over (w range between current row and unbounded following), +-- -- unique1, four +-- -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +-- -- +-- -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), +-- -- unique1, four +-- -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +-- +-- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +-- +-- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +-- +-- SELECT first_value(unique1) over w, +-- nth_value(unique1, 2) over w AS nth_2, +-- last_value(unique1) over w, unique1, four +-- FROM tenk1 WHERE unique1 < 10 +-- WINDOW w AS (order by four range between current row and unbounded following); + +-- broken +-- SELECT sum(unique1) over +-- (order by unique1 +-- rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), +-- unique1 +-- FROM tenk1 WHERE unique1 < 10; + + +-- we don't have a generate_series? +-- CREATE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following) as sum_rows +-- FROM generate_series(1, 10) i; +-- +-- SELECT * FROM v_window; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following +-- exclude current row) as sum_rows FROM generate_series(1, 10) i; +-- +-- SELECT * FROM v_window; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following +-- exclude group) as sum_rows FROM generate_series(1, 10) i; +-- +-- SELECT * FROM v_window; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following +-- exclude ties) as sum_rows FROM generate_series(1, 10) i; +-- +-- SELECT * FROM v_window; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following +-- exclude no others) as sum_rows FROM generate_series(1, 10) i; +-- +-- SELECT * FROM v_window; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM generate_series(1, 10) i; +-- +-- SELECT * FROM v_window; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- DROP VIEW v_window; +-- +-- CREATE TEMP VIEW v_window AS +-- SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i +-- FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i; +-- +-- SELECT pg_get_viewdef('v_window'); +-- +-- -- RANGE offset PRECEDING/FOLLOWING tests +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following +-- exclude current row),unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following), +-- salary, enroll_date from empsalary; +-- +-- select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following), +-- salary, enroll_date from empsalary; +-- +-- select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following), +-- salary, enroll_date from empsalary; +-- +-- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following +-- exclude current row), salary, enroll_date from empsalary; +-- +-- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following +-- exclude group), salary, enroll_date from empsalary; +-- +-- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following +-- exclude ties), salary, enroll_date from empsalary; +-- +-- select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), +-- lead(salary) over(order by salary range between 1000 preceding and 1000 following), +-- nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following), +-- salary from empsalary; +-- +-- select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), +-- lag(salary) over(order by salary range between 1000 preceding and 1000 following), +-- salary from empsalary; +-- +-- select first_value(salary) over(order by salary range between 1000 following and 3000 following +-- exclude current row), +-- lead(salary) over(order by salary range between 1000 following and 3000 following exclude ties), +-- nth_value(salary, 1) over(order by salary range between 1000 following and 3000 following +-- exclude ties), +-- salary from empsalary; +-- +-- select last_value(salary) over(order by salary range between 1000 following and 3000 following +-- exclude group), +-- lag(salary) over(order by salary range between 1000 following and 3000 following exclude group), +-- salary from empsalary; +-- +-- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude ties), +-- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following), +-- salary, enroll_date from empsalary; +-- +-- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude ties), +-- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude ties), +-- salary, enroll_date from empsalary; +-- +-- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude group), +-- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude group), +-- salary, enroll_date from empsalary; +-- +-- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude current row), +-- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- exclude current row), +-- salary, enroll_date from empsalary; +-- +-- -- RANGE offset PRECEDING/FOLLOWING with null values +-- select x, y, +-- first_value(y) over w, +-- last_value(y) over w +-- from +-- (select x, x as y from generate_series(1,5) as x +-- union all select null, 42 +-- union all select null, 43) ss +-- window w as +-- (order by x asc nulls first range between 2 preceding and 2 following); +-- +-- select x, y, +-- first_value(y) over w, +-- last_value(y) over w +-- from +-- (select x, x as y from generate_series(1,5) as x +-- union all select null, 42 +-- union all select null, 43) ss +-- window w as +-- (order by x asc nulls last range between 2 preceding and 2 following); +-- +-- select x, y, +-- first_value(y) over w, +-- last_value(y) over w +-- from +-- (select x, x as y from generate_series(1,5) as x +-- union all select null, 42 +-- union all select null, 43) ss +-- window w as +-- (order by x desc nulls first range between 2 preceding and 2 following); +-- +-- select x, y, +-- first_value(y) over w, +-- last_value(y) over w +-- from +-- (select x, x as y from generate_series(1,5) as x +-- union all select null, 42 +-- union all select null, 43) ss +-- window w as +-- (order by x desc nulls last range between 2 preceding and 2 following); +-- +-- -- Check overflow behavior for various integer sizes +-- +-- select x, last_value(x) over (order by x::smallint range between current row and 2147450884 following) +-- from generate_series(32764, 32766) x; +-- +-- select x, last_value(x) over (order by x::smallint desc range between current row and 2147450885 following) +-- from generate_series(-32766, -32764) x; +-- +-- select x, last_value(x) over (order by x range between current row and 4 following) +-- from generate_series(2147483644, 2147483646) x; +-- +-- select x, last_value(x) over (order by x desc range between current row and 5 following) +-- from generate_series(-2147483646, -2147483644) x; +-- +-- select x, last_value(x) over (order by x range between current row and 4 following) +-- from generate_series(9223372036854775804, 9223372036854775806) x; +-- +-- select x, last_value(x) over (order by x desc range between current row and 5 following) +-- from generate_series(-9223372036854775806, -9223372036854775804) x; +-- + +-- GROUPS tests +-- no `groups`? +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between current row and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- exclude current row), unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- exclude group), unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- exclude ties), unique1, four +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (partition by ten +-- order by four groups between 0 preceding and 0 following),unique1, four, ten +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (partition by ten +-- order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (partition by ten +-- order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten +-- FROM tenk1 WHERE unique1 < 10; +-- +-- SELECT sum(unique1) over (partition by ten +-- order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten +-- FROM tenk1 WHERE unique1 < 10; +-- +-- select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), +-- salary, enroll_date from empsalary; +-- +-- select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- salary, enroll_date from empsalary; +-- +-- select first_value(salary) over(order by enroll_date groups between 1 following and 3 following +-- exclude current row), +-- lead(salary) over(order by enroll_date groups between 1 following and 3 following exclude ties), +-- nth_value(salary, 1) over(order by enroll_date groups between 1 following and 3 following +-- exclude ties), +-- salary, enroll_date from empsalary; +-- +-- select last_value(salary) over(order by enroll_date groups between 1 following and 3 following +-- exclude group), +-- lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), +-- salary, enroll_date from empsalary; + +-- Show differences in offset interpretation between ROWS, RANGE, and GROUPS +-- WITH cte (x) AS ( +-- SELECT * FROM generate_series(1, 35, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); +-- +-- WITH cte (x) AS ( +-- SELECT * FROM generate_series(1, 35, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); + +-- WITH cte (x) AS ( +-- SELECT * FROM generate_series(1, 35, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); + +-- WITH cte (x) AS ( +-- select 1 union all select 1 union all select 1 union all +-- SELECT * FROM generate_series(5, 49, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); + +-- WITH cte (x) AS ( +-- select 1 union all select 1 union all select 1 union all +-- SELECT * FROM generate_series(5, 49, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); + +-- WITH cte (x) AS ( +-- select 1 union all select 1 union all select 1 union all +-- SELECT * FROM generate_series(5, 49, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); + +-- with UNION/we didn't have tenk2 yet +-- SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; + +-- check some degenerate cases +create table t1 (f1 int, f2 int) using parquet; +insert into t1 values (1,1),(1,2),(2,2); + +-- broken - costs and range are not available? +-- select f1, sum(f1) over (partition by f1 +-- range between 1 preceding and 1 following) +-- from t1 where f1 = f2; -- error, must have order by +-- explain (costs off) +-- select f1, sum(f1) over (partition by f1 order by f2 + -- range between 1 preceding and 1 following) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1 order by f2 +-- range between 1 preceding and 1 following) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1, f1 order by f2 +-- range between 2 preceding and 1 preceding) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1, f2 order by f2 +-- range between 1 following and 2 following) +-- from t1 where f1 = f2; + +-- select f1, sum(f1) over (partition by f1 +-- groups between 1 preceding and 1 following) +-- from t1 where f1 = f2; -- error, must have order by +-- explain (costs off) +-- select f1, sum(f1) over (partition by f1 order by f2 +-- groups between 1 preceding and 1 following) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1 order by f2 +-- groups between 1 preceding and 1 following) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1, f1 order by f2 +-- groups between 2 preceding and 1 preceding) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1, f2 order by f2 +-- groups between 1 following and 2 following) +-- from t1 where f1 = f2; + +-- ordering by a non-integer constant is allowed +SELECT rank() OVER (ORDER BY length('abc')); + +-- can't order by another window function +-- random does not exist +-- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); + +-- some other errors +-- broken +-- SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; + +-- SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; + +-- broken +-- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; + +-- broken +-- SELECT * FROM rank() OVER (ORDER BY random()); + +SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); + +-- broken +-- SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; + +SELECT count() OVER () FROM tenk1; + +-- SELECT generate_series(1, 100) OVER () FROM empsalary; + +-- the error is weird +-- SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; + +-- SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; + +-- filter +-- FILTER does not work on spark? +-- SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( +-- sum(salary) FILTER (WHERE enroll_date > '2007-01-01') +-- ) FILTER (WHERE depname <> 'sales') OVER (ORDER BY depname DESC) AS "filtered_sum", +-- depname +-- FROM empsalary GROUP BY depname; + +-- Test pushdown of quals into a subquery containing window functions + +-- costs off didn't work? +-- pushdown is safe because all PARTITION BY clauses include depname: +-- EXPLAIN (COSTS OFF) +-- SELECT * FROM +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY depname) depsalary, +-- min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary +-- FROM empsalary) emp +-- WHERE depname = 'sales'; + +-- pushdown is unsafe because there's a PARTITION BY clause without depname: +-- EXPLAIN (COSTS OFF) +-- SELECT * FROM +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, +-- min(salary) OVER (PARTITION BY depname) depminsalary +-- FROM empsalary) emp +-- WHERE depname = 'sales'; + +-- Test Sort node collapsing +-- EXPLAIN (COSTS OFF) +-- SELECT * FROM +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY depname order by empno) depsalary, +-- min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary +-- FROM empsalary) emp +-- WHERE depname = 'sales'; +-- +-- -- Test Sort node reordering +-- EXPLAIN (COSTS OFF) +-- SELECT +-- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), +-- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +-- FROM empsalary; + +-- test that returning NULL from the inverse transition functions +-- restarts the aggregation from scratch. The second aggregate is supposed +-- to test cases where only some aggregates restart, the third one checks +-- that one aggregate restarting doesn't cause others to restart. + + +-- WITH +-- vs AS ( +-- SELECT i, (random() * 100)::int4 AS v +-- FROM generate_series(1, 100) AS i +-- ), +-- sum_following AS ( +-- SELECT i, SUM(v) OVER +-- (ORDER BY i DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS s +-- FROM vs +-- ) +-- SELECT DISTINCT +-- sum_following.s = sum_int_randomrestart(v) OVER fwd AS eq1, +-- -sum_following.s = sum_int_randomrestart(-v) OVER fwd AS eq2, +-- 100*3+(vs.i-1)*3 = length(logging_agg_nonstrict(''::text) OVER fwd) AS eq3 +-- FROM vs +-- JOIN sum_following ON sum_following.i = vs.i +-- WINDOW fwd AS ( +-- ORDER BY vs.i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING +-- ); + + +-- Test various built-in aggregates that have moving-aggregate support + +-- test inverse transition functions handle NULLs properly +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v); + +SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n); + +SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); + +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); + +-- test that inverse transition functions work with various frame options +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); + +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v); + +-- bool_and? +-- SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w +-- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) +-- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out new file mode 100644 index 0000000000000..1c913896f8ff3 --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -0,0 +1,21407 @@ +-- Automatically generated by SQLQueryTestSuite +-- Number of queries: 92 + + +-- !query 0 +CREATE TABLE empsalary ( + depname string, + empno integer, + salary int, + enroll_date date +) USING parquet +-- !query 0 schema +struct<> +-- !query 0 output + + + +-- !query 1 +INSERT INTO empsalary VALUES +('develop', 10, 5200, '2007-08-01'), +('sales', 1, 5000, '2006-10-01'), +('personnel', 5, 3500, '2007-12-10'), +('sales', 4, 4800, '2007-08-08'), +('personnel', 2, 3900, '2006-12-23'), +('develop', 7, 4200, '2008-01-01'), +('develop', 9, 4500, '2008-01-01'), +('sales', 3, 4800, '2007-08-01'), +('develop', 8, 6000, '2006-10-01'), +('develop', 11, 5200, '2007-08-15') +-- !query 1 schema +struct<> +-- !query 1 output + + + +-- !query 2 +SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname) FROM empsalary ORDER BY depname, salary +-- !query 2 schema +struct +-- !query 2 output +develop 7 4200 25100 +develop 9 4500 25100 +develop 10 5200 25100 +develop 11 5200 25100 +develop 8 6000 25100 +personnel 5 3500 7400 +personnel 2 3900 7400 +sales 4 4800 14600 +sales 3 4800 14600 +sales 1 5000 14600 + + +-- !query 3 +SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary +-- !query 3 schema +struct +-- !query 3 output +develop 10 5200 3 +develop 11 5200 3 +develop 7 4200 1 +develop 8 6000 5 +develop 9 4500 2 +personnel 2 3900 2 +personnel 5 3500 1 +sales 1 5000 3 +sales 3 4800 1 +sales 4 4800 1 + + +-- !query 4 +SELECT four, ten, SUM(SUM(four)) OVER (PARTITION BY four), AVG(ten) FROM tenk1 +GROUP BY four, ten ORDER BY four, ten +-- !query 4 schema +struct +-- !query 4 output +0 0 0 0.0 +0 2 0 2.0 +0 4 0 4.0 +0 6 0 6.0 +0 8 0 8.0 +1 1 2500 1.0 +1 3 2500 3.0 +1 5 2500 5.0 +1 7 2500 7.0 +1 9 2500 9.0 +2 0 5000 0.0 +2 2 5000 2.0 +2 4 5000 4.0 +2 6 5000 6.0 +2 8 5000 8.0 +3 1 7500 1.0 +3 3 7500 3.0 +3 5 7500 5.0 +3 7 7500 7.0 +3 9 7500 9.0 + + +-- !query 5 +SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname) +-- !query 5 schema +struct +-- !query 5 output +develop 10 5200 25100 +develop 11 5200 25100 +develop 7 4200 25100 +develop 8 6000 25100 +develop 9 4500 25100 +personnel 2 3900 7400 +personnel 5 3500 7400 +sales 1 5000 14600 +sales 3 4800 14600 +sales 4 4800 14600 + + +-- !query 6 +SELECT depname, empno, salary, rank() OVER w as r FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY r +-- !query 6 schema +struct +-- !query 6 output +develop 7 4200 1 +sales 4 4800 1 +sales 3 4800 1 +personnel 5 3500 1 +develop 9 4500 2 +personnel 2 3900 2 +develop 10 5200 3 +develop 11 5200 3 +sales 1 5000 3 +develop 8 6000 5 + + +-- !query 7 +SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10 +-- !query 7 schema +struct +-- !query 7 output +10 +10 +10 +10 +10 +10 +10 +10 +10 +10 + + +-- !query 8 +SELECT COUNT(*) OVER w FROM tenk1 WHERE unique2 < 10 WINDOW w AS () +-- !query 8 schema +struct +-- !query 8 output +10 +10 +10 +10 +10 +10 +10 +10 +10 +10 + + +-- !query 9 +SELECT four FROM tenk1 WHERE FALSE WINDOW w AS (PARTITION BY ten) +-- !query 9 schema +struct +-- !query 9 output + + + +-- !query 10 +SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 10 schema +struct +-- !query 10 output +0 0 0 +0 0 0 +0 4 0 +1 7 1 +1 9 1 +2 0 2 +3 1 3 +3 3 3 +4 1 1 +5 1 1 + + +-- !query 11 +SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10 +-- !query 11 schema +struct +-- !query 11 output +1 +10 +2 +3 +4 +5 +6 +7 +8 +9 + + +-- !query 12 +SELECT rank() OVER (PARTITION BY four ORDER BY ten) AS rank_1, ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 12 schema +struct +-- !query 12 output +1 0 0 +1 0 0 +1 0 2 +1 1 1 +1 1 1 +1 1 3 +2 3 3 +3 4 0 +3 7 1 +4 9 1 + + +-- !query 13 +SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 13 schema +struct +-- !query 13 output +1 0 0 +1 0 0 +1 0 2 +1 1 1 +1 1 1 +1 1 3 +2 3 3 +2 4 0 +2 7 1 +3 9 1 + + +-- !query 14 +SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 14 schema +struct +-- !query 14 output +0.0 0 0 +0.0 0 0 +0.0 0 2 +0.0 1 1 +0.0 1 1 +0.0 1 3 +0.6666666666666666 7 1 +1.0 3 3 +1.0 4 0 +1.0 9 1 + + +-- !query 15 +SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 15 schema +struct +-- !query 15 output +0.5 1 1 +0.5 1 1 +0.5 1 3 +0.6666666666666666 0 0 +0.6666666666666666 0 0 +0.75 7 1 +1.0 0 2 +1.0 3 3 +1.0 4 0 +1.0 9 1 + + +-- !query 16 +SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 16 schema +struct +-- !query 16 output +1 0 0 +1 0 0 +1 0 2 +1 1 1 +2 1 1 +2 1 3 +2 3 3 +3 4 0 +3 7 1 +3 9 1 + + +-- !query 17 +SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 17 schema +struct +-- !query 17 output +0 0 0 +0 4 0 +1 1 1 +1 3 3 +1 7 1 +7 9 1 +NULL 0 0 +NULL 0 2 +NULL 1 1 +NULL 1 3 + + +-- !query 18 +SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 18 schema +struct +-- !query 18 output +0 0 0 +1 1 1 +3 1 3 +4 0 0 +7 1 1 +9 7 1 +NULL 0 2 +NULL 3 3 +NULL 4 0 +NULL 9 1 + + +-- !query 19 +SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 19 schema +struct +-- !query 19 output +0 0 0 +14 1 1 +18 7 1 +2 1 1 +6 1 3 +8 0 0 +NULL 0 2 +NULL 3 3 +NULL 4 0 +NULL 9 1 + + +-- !query 20 +SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 20 schema +struct +-- !query 20 output +-1 0 2 +-1 3 3 +-1 4 0 +-1 9 1 +0 0 0 +14 1 1 +18 7 1 +2 1 1 +6 1 3 +8 0 0 + + +-- !query 21 +SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 21 schema +struct +-- !query 21 output +0 0 0 +0 0 0 +0 0 2 +0 4 0 +1 1 1 +1 1 1 +1 1 3 +1 3 3 +1 7 1 +1 9 1 + + +-- !query 22 +SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- !query 22 schema +struct +-- !query 22 output +0 4 0 +1 1 1 +1 1 1 +1 1 3 +1 7 1 +1 9 1 +2 0 0 +2 0 0 +2 0 2 +3 3 3 + + +-- !query 23 +SELECT last_value(ten) OVER (PARTITION BY four), ten, four FROM +(SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s +ORDER BY four, ten +-- !query 23 schema +struct +-- !query 23 output +4 0 0 +4 0 0 +4 4 0 +9 1 1 +9 1 1 +9 7 1 +9 9 1 +0 0 2 +3 1 3 +3 3 3 + + +-- !query 24 +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER (PARTITION BY two ORDER BY ten) AS wsum +FROM tenk1 GROUP BY ten, two +-- !query 24 schema +struct +-- !query 24 output +0 0 45000 45000 +1 1 46000 46000 +2 0 47000 92000 +3 1 48000 94000 +4 0 49000 141000 +5 1 50000 144000 +6 0 51000 192000 +7 1 52000 196000 +8 0 53000 245000 +9 1 54000 250000 + + +-- !query 25 +SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10 +-- !query 25 schema +struct +-- !query 25 output +2 3 +2 3 +4 1 +4 1 +4 1 +4 1 + + +-- !query 26 +SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY four ORDER BY ten)) AS cntsum + FROM tenk1 WHERE unique2 < 10 +-- !query 26 schema +struct +-- !query 26 output +136 +22 +22 +24 +24 +51 +82 +87 +92 +92 + + +-- !query 27 +SELECT * FROM( + SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, + count(*) OVER (PARTITION BY four ORDER BY ten) AS fourcount, + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS twosum + FROM tenk1 +)sub WHERE total <> fourcount + twosum +-- !query 27 schema +struct +-- !query 27 output + + + +-- !query 28 +SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10 +-- !query 28 schema +struct +-- !query 28 output +0.0 +0.0 +0.0 +1.0 +1.0 +1.0 +1.0 +2.0 +3.0 +3.0 + + +-- !query 29 +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER win AS wsum +FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten) +-- !query 29 schema +struct +-- !query 29 output +0 0 45000 45000 +1 1 46000 46000 +2 0 47000 92000 +3 1 48000 94000 +4 0 49000 141000 +5 1 50000 144000 +6 0 51000 192000 +7 1 52000 196000 +8 0 53000 245000 +9 1 54000 250000 + + +-- !query 30 +SELECT sum(salary), +row_number() OVER (ORDER BY depname), +sum(sum(salary)) OVER (ORDER BY depname DESC) +FROM empsalary GROUP BY depname +-- !query 30 schema +struct +-- !query 30 output +14600 3 14600 +25100 1 47100 +7400 2 22000 + + +-- !query 31 +SELECT sum(salary) OVER w1, count(*) OVER w2 +FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary) +-- !query 31 schema +struct +-- !query 31 output +11600 3 +16100 4 +25700 6 +25700 6 +30700 7 +3500 1 +41100 9 +41100 9 +47100 10 +7400 2 + + +-- !query 32 +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s +-- !query 32 schema +struct +-- !query 32 output + + + +-- !query 33 +SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) +-- !query 33 schema +struct +-- !query 33 output +14600 2 +14600 2 +16400 2 +16400 2 +20900 4 +25100 5 +3900 1 +5000 1 +6000 1 +7400 2 + + +-- !query 34 +SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( + SELECT *, + CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus, + CASE WHEN + AVG(salary) OVER (PARTITION BY depname) < salary + THEN 200 END AS depadj FROM empsalary + )s +-- !query 34 schema +struct +-- !query 34 output +1 sales 5000 1000 200 1000 200 +10 develop 5200 500 200 500 200 +11 develop 5200 500 200 500 200 +2 personnel 3900 1000 200 1000 200 +3 sales 4800 500 NULL 500 200 +4 sales 4800 500 NULL 500 200 +5 personnel 3500 500 NULL 500 200 +7 develop 4200 NULL NULL 500 200 +8 develop 6000 1000 200 500 200 +9 develop 4500 NULL NULL 500 200 + + +-- !query 35 +create temporary view int4_tbl as select * from values + (0), + (123456), + (-123456), + (2147483647), + (-2147483647) + as int4_tbl(f1) +-- !query 35 schema +struct<> +-- !query 35 output + + + +-- !query 36 +SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 +-- !query 36 schema +struct +-- !query 36 output +0 + + +-- !query 37 +select ten, + sum(unique1) + sum(unique2) as res, + rank() over (order by sum(unique1) + sum(unique2)) as rank +from tenk1 +group by ten order by ten +-- !query 37 schema +struct +-- !query 37 output +0 9976146 4 +1 10114187 9 +2 10059554 8 +3 9878541 1 +4 9881005 2 +5 9981670 5 +6 9947099 3 +7 10120309 10 +8 9991305 6 +9 10040184 7 + + +-- !query 38 +SELECT four, ten, +sum(ten) over (partition by four order by ten), +last_value(ten) over (partition by four order by ten) +FROM (select distinct ten, four from tenk1) ss +-- !query 38 schema +struct +-- !query 38 output +0 0 0 0 +0 2 2 2 +0 4 6 4 +0 6 12 6 +0 8 20 8 +1 1 1 1 +1 3 4 3 +1 5 9 5 +1 7 16 7 +1 9 25 9 +2 0 0 0 +2 2 2 2 +2 4 6 4 +2 6 12 6 +2 8 20 8 +3 1 1 1 +3 3 4 3 +3 5 9 5 +3 7 16 7 +3 9 25 9 + + +-- !query 39 +SELECT four, ten, +sum(ten) over (partition by four order by ten range between unbounded preceding and current row), +last_value(ten) over (partition by four order by ten range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- !query 39 schema +struct +-- !query 39 output +0 0 0 0 +0 2 2 2 +0 4 6 4 +0 6 12 6 +0 8 20 8 +1 1 1 1 +1 3 4 3 +1 5 9 5 +1 7 16 7 +1 9 25 9 +2 0 0 0 +2 2 2 2 +2 4 6 4 +2 6 12 6 +2 8 20 8 +3 1 1 1 +3 3 4 3 +3 5 9 5 +3 7 16 7 +3 9 25 9 + + +-- !query 40 +SELECT four, ten, +sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following), +last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) +FROM (select distinct ten, four from tenk1) ss +-- !query 40 schema +struct +-- !query 40 output +0 0 20 8 +0 2 20 8 +0 4 20 8 +0 6 20 8 +0 8 20 8 +1 1 25 9 +1 3 25 9 +1 5 25 9 +1 7 25 9 +1 9 25 9 +2 0 20 8 +2 2 20 8 +2 4 20 8 +2 6 20 8 +2 8 20 8 +3 1 25 9 +3 3 25 9 +3 5 25 9 +3 7 25 9 +3 9 25 9 + + +-- !query 41 +SELECT four, ten/4 as two, +sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row), +last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- !query 41 schema +struct +-- !query 41 output +0 0.0 0.0 0.0 +0 0.5 0.5 0.5 +0 1.0 1.5 1.0 +0 1.5 3.0 1.5 +0 2.0 5.0 2.0 +1 0.25 0.25 0.25 +1 0.75 1.0 0.75 +1 1.25 2.25 1.25 +1 1.75 4.0 1.75 +1 2.25 6.25 2.25 +2 0.0 0.0 0.0 +2 0.5 0.5 0.5 +2 1.0 1.5 1.0 +2 1.5 3.0 1.5 +2 2.0 5.0 2.0 +3 0.25 0.25 0.25 +3 0.75 1.0 0.75 +3 1.25 2.25 1.25 +3 1.75 4.0 1.75 +3 2.25 6.25 2.25 + + +-- !query 42 +SELECT four, ten/4 as two, +sum(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row), +last_value(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- !query 42 schema +struct +-- !query 42 output +0 0.0 0.0 0.0 +0 0.5 0.5 0.5 +0 1.0 1.5 1.0 +0 1.5 3.0 1.5 +0 2.0 5.0 2.0 +1 0.25 0.25 0.25 +1 0.75 1.0 0.75 +1 1.25 2.25 1.25 +1 1.75 4.0 1.75 +1 2.25 6.25 2.25 +2 0.0 0.0 0.0 +2 0.5 0.5 0.5 +2 1.0 1.5 1.0 +2 1.5 3.0 1.5 +2 2.0 5.0 2.0 +3 0.25 0.25 0.25 +3 0.75 1.0 0.75 +3 1.25 2.25 1.25 +3 1.75 4.0 1.75 +3 2.25 6.25 2.25 + + +-- !query 43 +SELECT sum(unique1) over (order by four range between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 43 schema +struct +-- !query 43 output +10 3 3 +10 7 3 +18 2 2 +18 6 2 +33 1 1 +33 5 1 +33 9 1 +45 0 0 +45 4 0 +45 8 0 + + +-- !query 44 +SELECT sum(unique1) over (rows between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 44 schema +struct +-- !query 44 output +0 0 0 +10 3 3 +15 5 1 +23 8 0 +32 9 1 +38 6 2 +39 1 1 +41 2 2 +45 4 0 +7 7 3 + + +-- !query 45 +SELECT sum(unique1) over (rows between 2 preceding and 2 following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 45 schema +struct +-- !query 45 output +10 0 0 +13 2 2 +15 7 3 +22 1 1 +23 3 3 +26 6 2 +29 9 1 +31 8 0 +32 5 1 +7 4 0 + + +-- !query 46 +create table t1 (f1 int, f2 int) using parquet +-- !query 46 schema +struct<> +-- !query 46 output + + + +-- !query 47 +insert into t1 values (1,1),(1,2),(2,2) +-- !query 47 schema +struct<> +-- !query 47 output + + + +-- !query 48 +-- range between 1 preceding and 1 following) + + +SELECT rank() OVER (ORDER BY length('abc')) +-- !query 48 schema +struct +-- !query 48 output +1 + + +-- !query 49 +SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1) +-- !query 49 schema +struct +-- !query 49 output +1 +10 +100 +1000 +10000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +101 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +102 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +103 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +104 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +105 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +106 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +107 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +108 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +109 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +11 +110 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +111 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +112 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +113 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +114 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +115 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +116 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +117 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +118 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +119 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +12 +120 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +121 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +122 +1220 +1221 +1222 +1223 +1224 +1225 +1226 +1227 +1228 +1229 +123 +1230 +1231 +1232 +1233 +1234 +1235 +1236 +1237 +1238 +1239 +124 +1240 +1241 +1242 +1243 +1244 +1245 +1246 +1247 +1248 +1249 +125 +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +126 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +127 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278 +1279 +128 +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +129 +1290 +1291 +1292 +1293 +1294 +1295 +1296 +1297 +1298 +1299 +13 +130 +1300 +1301 +1302 +1303 +1304 +1305 +1306 +1307 +1308 +1309 +131 +1310 +1311 +1312 +1313 +1314 +1315 +1316 +1317 +1318 +1319 +132 +1320 +1321 +1322 +1323 +1324 +1325 +1326 +1327 +1328 +1329 +133 +1330 +1331 +1332 +1333 +1334 +1335 +1336 +1337 +1338 +1339 +134 +1340 +1341 +1342 +1343 +1344 +1345 +1346 +1347 +1348 +1349 +135 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +136 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 +137 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +138 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387 +1388 +1389 +139 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +14 +140 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409 +141 +1410 +1411 +1412 +1413 +1414 +1415 +1416 +1417 +1418 +1419 +142 +1420 +1421 +1422 +1423 +1424 +1425 +1426 +1427 +1428 +1429 +143 +1430 +1431 +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +144 +1440 +1441 +1442 +1443 +1444 +1445 +1446 +1447 +1448 +1449 +145 +1450 +1451 +1452 +1453 +1454 +1455 +1456 +1457 +1458 +1459 +146 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +147 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +148 +1480 +1481 +1482 +1483 +1484 +1485 +1486 +1487 +1488 +1489 +149 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +15 +150 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +151 +1510 +1511 +1512 +1513 +1514 +1515 +1516 +1517 +1518 +1519 +152 +1520 +1521 +1522 +1523 +1524 +1525 +1526 +1527 +1528 +1529 +153 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539 +154 +1540 +1541 +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +155 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +156 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +157 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +158 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +159 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +16 +160 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +161 +1610 +1611 +1612 +1613 +1614 +1615 +1616 +1617 +1618 +1619 +162 +1620 +1621 +1622 +1623 +1624 +1625 +1626 +1627 +1628 +1629 +163 +1630 +1631 +1632 +1633 +1634 +1635 +1636 +1637 +1638 +1639 +164 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +165 +1650 +1651 +1652 +1653 +1654 +1655 +1656 +1657 +1658 +1659 +166 +1660 +1661 +1662 +1663 +1664 +1665 +1666 +1667 +1668 +1669 +167 +1670 +1671 +1672 +1673 +1674 +1675 +1676 +1677 +1678 +1679 +168 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +169 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +17 +170 +1700 +1701 +1702 +1703 +1704 +1705 +1706 +1707 +1708 +1709 +171 +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +172 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729 +173 +1730 +1731 +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +174 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +175 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +176 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +177 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +178 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789 +179 +1790 +1791 +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +18 +180 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +181 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +182 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +183 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +184 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +185 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +186 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +187 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +188 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +189 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898 +1899 +19 +190 +1900 +1901 +1902 +1903 +1904 +1905 +1906 +1907 +1908 +1909 +191 +1910 +1911 +1912 +1913 +1914 +1915 +1916 +1917 +1918 +1919 +192 +1920 +1921 +1922 +1923 +1924 +1925 +1926 +1927 +1928 +1929 +193 +1930 +1931 +1932 +1933 +1934 +1935 +1936 +1937 +1938 +1939 +194 +1940 +1941 +1942 +1943 +1944 +1945 +1946 +1947 +1948 +1949 +195 +1950 +1951 +1952 +1953 +1954 +1955 +1956 +1957 +1958 +1959 +196 +1960 +1961 +1962 +1963 +1964 +1965 +1966 +1967 +1968 +1969 +197 +1970 +1971 +1972 +1973 +1974 +1975 +1976 +1977 +1978 +1979 +198 +1980 +1981 +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +199 +1990 +1991 +1992 +1993 +1994 +1995 +1996 +1997 +1998 +1999 +2 +20 +200 +2000 +2001 +2002 +2003 +2004 +2005 +2006 +2007 +2008 +2009 +201 +2010 +2011 +2012 +2013 +2014 +2015 +2016 +2017 +2018 +2019 +202 +2020 +2021 +2022 +2023 +2024 +2025 +2026 +2027 +2028 +2029 +203 +2030 +2031 +2032 +2033 +2034 +2035 +2036 +2037 +2038 +2039 +204 +2040 +2041 +2042 +2043 +2044 +2045 +2046 +2047 +2048 +2049 +205 +2050 +2051 +2052 +2053 +2054 +2055 +2056 +2057 +2058 +2059 +206 +2060 +2061 +2062 +2063 +2064 +2065 +2066 +2067 +2068 +2069 +207 +2070 +2071 +2072 +2073 +2074 +2075 +2076 +2077 +2078 +2079 +208 +2080 +2081 +2082 +2083 +2084 +2085 +2086 +2087 +2088 +2089 +209 +2090 +2091 +2092 +2093 +2094 +2095 +2096 +2097 +2098 +2099 +21 +210 +2100 +2101 +2102 +2103 +2104 +2105 +2106 +2107 +2108 +2109 +211 +2110 +2111 +2112 +2113 +2114 +2115 +2116 +2117 +2118 +2119 +212 +2120 +2121 +2122 +2123 +2124 +2125 +2126 +2127 +2128 +2129 +213 +2130 +2131 +2132 +2133 +2134 +2135 +2136 +2137 +2138 +2139 +214 +2140 +2141 +2142 +2143 +2144 +2145 +2146 +2147 +2148 +2149 +215 +2150 +2151 +2152 +2153 +2154 +2155 +2156 +2157 +2158 +2159 +216 +2160 +2161 +2162 +2163 +2164 +2165 +2166 +2167 +2168 +2169 +217 +2170 +2171 +2172 +2173 +2174 +2175 +2176 +2177 +2178 +2179 +218 +2180 +2181 +2182 +2183 +2184 +2185 +2186 +2187 +2188 +2189 +219 +2190 +2191 +2192 +2193 +2194 +2195 +2196 +2197 +2198 +2199 +22 +220 +2200 +2201 +2202 +2203 +2204 +2205 +2206 +2207 +2208 +2209 +221 +2210 +2211 +2212 +2213 +2214 +2215 +2216 +2217 +2218 +2219 +222 +2220 +2221 +2222 +2223 +2224 +2225 +2226 +2227 +2228 +2229 +223 +2230 +2231 +2232 +2233 +2234 +2235 +2236 +2237 +2238 +2239 +224 +2240 +2241 +2242 +2243 +2244 +2245 +2246 +2247 +2248 +2249 +225 +2250 +2251 +2252 +2253 +2254 +2255 +2256 +2257 +2258 +2259 +226 +2260 +2261 +2262 +2263 +2264 +2265 +2266 +2267 +2268 +2269 +227 +2270 +2271 +2272 +2273 +2274 +2275 +2276 +2277 +2278 +2279 +228 +2280 +2281 +2282 +2283 +2284 +2285 +2286 +2287 +2288 +2289 +229 +2290 +2291 +2292 +2293 +2294 +2295 +2296 +2297 +2298 +2299 +23 +230 +2300 +2301 +2302 +2303 +2304 +2305 +2306 +2307 +2308 +2309 +231 +2310 +2311 +2312 +2313 +2314 +2315 +2316 +2317 +2318 +2319 +232 +2320 +2321 +2322 +2323 +2324 +2325 +2326 +2327 +2328 +2329 +233 +2330 +2331 +2332 +2333 +2334 +2335 +2336 +2337 +2338 +2339 +234 +2340 +2341 +2342 +2343 +2344 +2345 +2346 +2347 +2348 +2349 +235 +2350 +2351 +2352 +2353 +2354 +2355 +2356 +2357 +2358 +2359 +236 +2360 +2361 +2362 +2363 +2364 +2365 +2366 +2367 +2368 +2369 +237 +2370 +2371 +2372 +2373 +2374 +2375 +2376 +2377 +2378 +2379 +238 +2380 +2381 +2382 +2383 +2384 +2385 +2386 +2387 +2388 +2389 +239 +2390 +2391 +2392 +2393 +2394 +2395 +2396 +2397 +2398 +2399 +24 +240 +2400 +2401 +2402 +2403 +2404 +2405 +2406 +2407 +2408 +2409 +241 +2410 +2411 +2412 +2413 +2414 +2415 +2416 +2417 +2418 +2419 +242 +2420 +2421 +2422 +2423 +2424 +2425 +2426 +2427 +2428 +2429 +243 +2430 +2431 +2432 +2433 +2434 +2435 +2436 +2437 +2438 +2439 +244 +2440 +2441 +2442 +2443 +2444 +2445 +2446 +2447 +2448 +2449 +245 +2450 +2451 +2452 +2453 +2454 +2455 +2456 +2457 +2458 +2459 +246 +2460 +2461 +2462 +2463 +2464 +2465 +2466 +2467 +2468 +2469 +247 +2470 +2471 +2472 +2473 +2474 +2475 +2476 +2477 +2478 +2479 +248 +2480 +2481 +2482 +2483 +2484 +2485 +2486 +2487 +2488 +2489 +249 +2490 +2491 +2492 +2493 +2494 +2495 +2496 +2497 +2498 +2499 +25 +250 +2500 +2501 +2502 +2503 +2504 +2505 +2506 +2507 +2508 +2509 +251 +2510 +2511 +2512 +2513 +2514 +2515 +2516 +2517 +2518 +2519 +252 +2520 +2521 +2522 +2523 +2524 +2525 +2526 +2527 +2528 +2529 +253 +2530 +2531 +2532 +2533 +2534 +2535 +2536 +2537 +2538 +2539 +254 +2540 +2541 +2542 +2543 +2544 +2545 +2546 +2547 +2548 +2549 +255 +2550 +2551 +2552 +2553 +2554 +2555 +2556 +2557 +2558 +2559 +256 +2560 +2561 +2562 +2563 +2564 +2565 +2566 +2567 +2568 +2569 +257 +2570 +2571 +2572 +2573 +2574 +2575 +2576 +2577 +2578 +2579 +258 +2580 +2581 +2582 +2583 +2584 +2585 +2586 +2587 +2588 +2589 +259 +2590 +2591 +2592 +2593 +2594 +2595 +2596 +2597 +2598 +2599 +26 +260 +2600 +2601 +2602 +2603 +2604 +2605 +2606 +2607 +2608 +2609 +261 +2610 +2611 +2612 +2613 +2614 +2615 +2616 +2617 +2618 +2619 +262 +2620 +2621 +2622 +2623 +2624 +2625 +2626 +2627 +2628 +2629 +263 +2630 +2631 +2632 +2633 +2634 +2635 +2636 +2637 +2638 +2639 +264 +2640 +2641 +2642 +2643 +2644 +2645 +2646 +2647 +2648 +2649 +265 +2650 +2651 +2652 +2653 +2654 +2655 +2656 +2657 +2658 +2659 +266 +2660 +2661 +2662 +2663 +2664 +2665 +2666 +2667 +2668 +2669 +267 +2670 +2671 +2672 +2673 +2674 +2675 +2676 +2677 +2678 +2679 +268 +2680 +2681 +2682 +2683 +2684 +2685 +2686 +2687 +2688 +2689 +269 +2690 +2691 +2692 +2693 +2694 +2695 +2696 +2697 +2698 +2699 +27 +270 +2700 +2701 +2702 +2703 +2704 +2705 +2706 +2707 +2708 +2709 +271 +2710 +2711 +2712 +2713 +2714 +2715 +2716 +2717 +2718 +2719 +272 +2720 +2721 +2722 +2723 +2724 +2725 +2726 +2727 +2728 +2729 +273 +2730 +2731 +2732 +2733 +2734 +2735 +2736 +2737 +2738 +2739 +274 +2740 +2741 +2742 +2743 +2744 +2745 +2746 +2747 +2748 +2749 +275 +2750 +2751 +2752 +2753 +2754 +2755 +2756 +2757 +2758 +2759 +276 +2760 +2761 +2762 +2763 +2764 +2765 +2766 +2767 +2768 +2769 +277 +2770 +2771 +2772 +2773 +2774 +2775 +2776 +2777 +2778 +2779 +278 +2780 +2781 +2782 +2783 +2784 +2785 +2786 +2787 +2788 +2789 +279 +2790 +2791 +2792 +2793 +2794 +2795 +2796 +2797 +2798 +2799 +28 +280 +2800 +2801 +2802 +2803 +2804 +2805 +2806 +2807 +2808 +2809 +281 +2810 +2811 +2812 +2813 +2814 +2815 +2816 +2817 +2818 +2819 +282 +2820 +2821 +2822 +2823 +2824 +2825 +2826 +2827 +2828 +2829 +283 +2830 +2831 +2832 +2833 +2834 +2835 +2836 +2837 +2838 +2839 +284 +2840 +2841 +2842 +2843 +2844 +2845 +2846 +2847 +2848 +2849 +285 +2850 +2851 +2852 +2853 +2854 +2855 +2856 +2857 +2858 +2859 +286 +2860 +2861 +2862 +2863 +2864 +2865 +2866 +2867 +2868 +2869 +287 +2870 +2871 +2872 +2873 +2874 +2875 +2876 +2877 +2878 +2879 +288 +2880 +2881 +2882 +2883 +2884 +2885 +2886 +2887 +2888 +2889 +289 +2890 +2891 +2892 +2893 +2894 +2895 +2896 +2897 +2898 +2899 +29 +290 +2900 +2901 +2902 +2903 +2904 +2905 +2906 +2907 +2908 +2909 +291 +2910 +2911 +2912 +2913 +2914 +2915 +2916 +2917 +2918 +2919 +292 +2920 +2921 +2922 +2923 +2924 +2925 +2926 +2927 +2928 +2929 +293 +2930 +2931 +2932 +2933 +2934 +2935 +2936 +2937 +2938 +2939 +294 +2940 +2941 +2942 +2943 +2944 +2945 +2946 +2947 +2948 +2949 +295 +2950 +2951 +2952 +2953 +2954 +2955 +2956 +2957 +2958 +2959 +296 +2960 +2961 +2962 +2963 +2964 +2965 +2966 +2967 +2968 +2969 +297 +2970 +2971 +2972 +2973 +2974 +2975 +2976 +2977 +2978 +2979 +298 +2980 +2981 +2982 +2983 +2984 +2985 +2986 +2987 +2988 +2989 +299 +2990 +2991 +2992 +2993 +2994 +2995 +2996 +2997 +2998 +2999 +3 +30 +300 +3000 +3001 +3002 +3003 +3004 +3005 +3006 +3007 +3008 +3009 +301 +3010 +3011 +3012 +3013 +3014 +3015 +3016 +3017 +3018 +3019 +302 +3020 +3021 +3022 +3023 +3024 +3025 +3026 +3027 +3028 +3029 +303 +3030 +3031 +3032 +3033 +3034 +3035 +3036 +3037 +3038 +3039 +304 +3040 +3041 +3042 +3043 +3044 +3045 +3046 +3047 +3048 +3049 +305 +3050 +3051 +3052 +3053 +3054 +3055 +3056 +3057 +3058 +3059 +306 +3060 +3061 +3062 +3063 +3064 +3065 +3066 +3067 +3068 +3069 +307 +3070 +3071 +3072 +3073 +3074 +3075 +3076 +3077 +3078 +3079 +308 +3080 +3081 +3082 +3083 +3084 +3085 +3086 +3087 +3088 +3089 +309 +3090 +3091 +3092 +3093 +3094 +3095 +3096 +3097 +3098 +3099 +31 +310 +3100 +3101 +3102 +3103 +3104 +3105 +3106 +3107 +3108 +3109 +311 +3110 +3111 +3112 +3113 +3114 +3115 +3116 +3117 +3118 +3119 +312 +3120 +3121 +3122 +3123 +3124 +3125 +3126 +3127 +3128 +3129 +313 +3130 +3131 +3132 +3133 +3134 +3135 +3136 +3137 +3138 +3139 +314 +3140 +3141 +3142 +3143 +3144 +3145 +3146 +3147 +3148 +3149 +315 +3150 +3151 +3152 +3153 +3154 +3155 +3156 +3157 +3158 +3159 +316 +3160 +3161 +3162 +3163 +3164 +3165 +3166 +3167 +3168 +3169 +317 +3170 +3171 +3172 +3173 +3174 +3175 +3176 +3177 +3178 +3179 +318 +3180 +3181 +3182 +3183 +3184 +3185 +3186 +3187 +3188 +3189 +319 +3190 +3191 +3192 +3193 +3194 +3195 +3196 +3197 +3198 +3199 +32 +320 +3200 +3201 +3202 +3203 +3204 +3205 +3206 +3207 +3208 +3209 +321 +3210 +3211 +3212 +3213 +3214 +3215 +3216 +3217 +3218 +3219 +322 +3220 +3221 +3222 +3223 +3224 +3225 +3226 +3227 +3228 +3229 +323 +3230 +3231 +3232 +3233 +3234 +3235 +3236 +3237 +3238 +3239 +324 +3240 +3241 +3242 +3243 +3244 +3245 +3246 +3247 +3248 +3249 +325 +3250 +3251 +3252 +3253 +3254 +3255 +3256 +3257 +3258 +3259 +326 +3260 +3261 +3262 +3263 +3264 +3265 +3266 +3267 +3268 +3269 +327 +3270 +3271 +3272 +3273 +3274 +3275 +3276 +3277 +3278 +3279 +328 +3280 +3281 +3282 +3283 +3284 +3285 +3286 +3287 +3288 +3289 +329 +3290 +3291 +3292 +3293 +3294 +3295 +3296 +3297 +3298 +3299 +33 +330 +3300 +3301 +3302 +3303 +3304 +3305 +3306 +3307 +3308 +3309 +331 +3310 +3311 +3312 +3313 +3314 +3315 +3316 +3317 +3318 +3319 +332 +3320 +3321 +3322 +3323 +3324 +3325 +3326 +3327 +3328 +3329 +333 +3330 +3331 +3332 +3333 +3334 +3335 +3336 +3337 +3338 +3339 +334 +3340 +3341 +3342 +3343 +3344 +3345 +3346 +3347 +3348 +3349 +335 +3350 +3351 +3352 +3353 +3354 +3355 +3356 +3357 +3358 +3359 +336 +3360 +3361 +3362 +3363 +3364 +3365 +3366 +3367 +3368 +3369 +337 +3370 +3371 +3372 +3373 +3374 +3375 +3376 +3377 +3378 +3379 +338 +3380 +3381 +3382 +3383 +3384 +3385 +3386 +3387 +3388 +3389 +339 +3390 +3391 +3392 +3393 +3394 +3395 +3396 +3397 +3398 +3399 +34 +340 +3400 +3401 +3402 +3403 +3404 +3405 +3406 +3407 +3408 +3409 +341 +3410 +3411 +3412 +3413 +3414 +3415 +3416 +3417 +3418 +3419 +342 +3420 +3421 +3422 +3423 +3424 +3425 +3426 +3427 +3428 +3429 +343 +3430 +3431 +3432 +3433 +3434 +3435 +3436 +3437 +3438 +3439 +344 +3440 +3441 +3442 +3443 +3444 +3445 +3446 +3447 +3448 +3449 +345 +3450 +3451 +3452 +3453 +3454 +3455 +3456 +3457 +3458 +3459 +346 +3460 +3461 +3462 +3463 +3464 +3465 +3466 +3467 +3468 +3469 +347 +3470 +3471 +3472 +3473 +3474 +3475 +3476 +3477 +3478 +3479 +348 +3480 +3481 +3482 +3483 +3484 +3485 +3486 +3487 +3488 +3489 +349 +3490 +3491 +3492 +3493 +3494 +3495 +3496 +3497 +3498 +3499 +35 +350 +3500 +3501 +3502 +3503 +3504 +3505 +3506 +3507 +3508 +3509 +351 +3510 +3511 +3512 +3513 +3514 +3515 +3516 +3517 +3518 +3519 +352 +3520 +3521 +3522 +3523 +3524 +3525 +3526 +3527 +3528 +3529 +353 +3530 +3531 +3532 +3533 +3534 +3535 +3536 +3537 +3538 +3539 +354 +3540 +3541 +3542 +3543 +3544 +3545 +3546 +3547 +3548 +3549 +355 +3550 +3551 +3552 +3553 +3554 +3555 +3556 +3557 +3558 +3559 +356 +3560 +3561 +3562 +3563 +3564 +3565 +3566 +3567 +3568 +3569 +357 +3570 +3571 +3572 +3573 +3574 +3575 +3576 +3577 +3578 +3579 +358 +3580 +3581 +3582 +3583 +3584 +3585 +3586 +3587 +3588 +3589 +359 +3590 +3591 +3592 +3593 +3594 +3595 +3596 +3597 +3598 +3599 +36 +360 +3600 +3601 +3602 +3603 +3604 +3605 +3606 +3607 +3608 +3609 +361 +3610 +3611 +3612 +3613 +3614 +3615 +3616 +3617 +3618 +3619 +362 +3620 +3621 +3622 +3623 +3624 +3625 +3626 +3627 +3628 +3629 +363 +3630 +3631 +3632 +3633 +3634 +3635 +3636 +3637 +3638 +3639 +364 +3640 +3641 +3642 +3643 +3644 +3645 +3646 +3647 +3648 +3649 +365 +3650 +3651 +3652 +3653 +3654 +3655 +3656 +3657 +3658 +3659 +366 +3660 +3661 +3662 +3663 +3664 +3665 +3666 +3667 +3668 +3669 +367 +3670 +3671 +3672 +3673 +3674 +3675 +3676 +3677 +3678 +3679 +368 +3680 +3681 +3682 +3683 +3684 +3685 +3686 +3687 +3688 +3689 +369 +3690 +3691 +3692 +3693 +3694 +3695 +3696 +3697 +3698 +3699 +37 +370 +3700 +3701 +3702 +3703 +3704 +3705 +3706 +3707 +3708 +3709 +371 +3710 +3711 +3712 +3713 +3714 +3715 +3716 +3717 +3718 +3719 +372 +3720 +3721 +3722 +3723 +3724 +3725 +3726 +3727 +3728 +3729 +373 +3730 +3731 +3732 +3733 +3734 +3735 +3736 +3737 +3738 +3739 +374 +3740 +3741 +3742 +3743 +3744 +3745 +3746 +3747 +3748 +3749 +375 +3750 +3751 +3752 +3753 +3754 +3755 +3756 +3757 +3758 +3759 +376 +3760 +3761 +3762 +3763 +3764 +3765 +3766 +3767 +3768 +3769 +377 +3770 +3771 +3772 +3773 +3774 +3775 +3776 +3777 +3778 +3779 +378 +3780 +3781 +3782 +3783 +3784 +3785 +3786 +3787 +3788 +3789 +379 +3790 +3791 +3792 +3793 +3794 +3795 +3796 +3797 +3798 +3799 +38 +380 +3800 +3801 +3802 +3803 +3804 +3805 +3806 +3807 +3808 +3809 +381 +3810 +3811 +3812 +3813 +3814 +3815 +3816 +3817 +3818 +3819 +382 +3820 +3821 +3822 +3823 +3824 +3825 +3826 +3827 +3828 +3829 +383 +3830 +3831 +3832 +3833 +3834 +3835 +3836 +3837 +3838 +3839 +384 +3840 +3841 +3842 +3843 +3844 +3845 +3846 +3847 +3848 +3849 +385 +3850 +3851 +3852 +3853 +3854 +3855 +3856 +3857 +3858 +3859 +386 +3860 +3861 +3862 +3863 +3864 +3865 +3866 +3867 +3868 +3869 +387 +3870 +3871 +3872 +3873 +3874 +3875 +3876 +3877 +3878 +3879 +388 +3880 +3881 +3882 +3883 +3884 +3885 +3886 +3887 +3888 +3889 +389 +3890 +3891 +3892 +3893 +3894 +3895 +3896 +3897 +3898 +3899 +39 +390 +3900 +3901 +3902 +3903 +3904 +3905 +3906 +3907 +3908 +3909 +391 +3910 +3911 +3912 +3913 +3914 +3915 +3916 +3917 +3918 +3919 +392 +3920 +3921 +3922 +3923 +3924 +3925 +3926 +3927 +3928 +3929 +393 +3930 +3931 +3932 +3933 +3934 +3935 +3936 +3937 +3938 +3939 +394 +3940 +3941 +3942 +3943 +3944 +3945 +3946 +3947 +3948 +3949 +395 +3950 +3951 +3952 +3953 +3954 +3955 +3956 +3957 +3958 +3959 +396 +3960 +3961 +3962 +3963 +3964 +3965 +3966 +3967 +3968 +3969 +397 +3970 +3971 +3972 +3973 +3974 +3975 +3976 +3977 +3978 +3979 +398 +3980 +3981 +3982 +3983 +3984 +3985 +3986 +3987 +3988 +3989 +399 +3990 +3991 +3992 +3993 +3994 +3995 +3996 +3997 +3998 +3999 +4 +40 +400 +4000 +4001 +4002 +4003 +4004 +4005 +4006 +4007 +4008 +4009 +401 +4010 +4011 +4012 +4013 +4014 +4015 +4016 +4017 +4018 +4019 +402 +4020 +4021 +4022 +4023 +4024 +4025 +4026 +4027 +4028 +4029 +403 +4030 +4031 +4032 +4033 +4034 +4035 +4036 +4037 +4038 +4039 +404 +4040 +4041 +4042 +4043 +4044 +4045 +4046 +4047 +4048 +4049 +405 +4050 +4051 +4052 +4053 +4054 +4055 +4056 +4057 +4058 +4059 +406 +4060 +4061 +4062 +4063 +4064 +4065 +4066 +4067 +4068 +4069 +407 +4070 +4071 +4072 +4073 +4074 +4075 +4076 +4077 +4078 +4079 +408 +4080 +4081 +4082 +4083 +4084 +4085 +4086 +4087 +4088 +4089 +409 +4090 +4091 +4092 +4093 +4094 +4095 +4096 +4097 +4098 +4099 +41 +410 +4100 +4101 +4102 +4103 +4104 +4105 +4106 +4107 +4108 +4109 +411 +4110 +4111 +4112 +4113 +4114 +4115 +4116 +4117 +4118 +4119 +412 +4120 +4121 +4122 +4123 +4124 +4125 +4126 +4127 +4128 +4129 +413 +4130 +4131 +4132 +4133 +4134 +4135 +4136 +4137 +4138 +4139 +414 +4140 +4141 +4142 +4143 +4144 +4145 +4146 +4147 +4148 +4149 +415 +4150 +4151 +4152 +4153 +4154 +4155 +4156 +4157 +4158 +4159 +416 +4160 +4161 +4162 +4163 +4164 +4165 +4166 +4167 +4168 +4169 +417 +4170 +4171 +4172 +4173 +4174 +4175 +4176 +4177 +4178 +4179 +418 +4180 +4181 +4182 +4183 +4184 +4185 +4186 +4187 +4188 +4189 +419 +4190 +4191 +4192 +4193 +4194 +4195 +4196 +4197 +4198 +4199 +42 +420 +4200 +4201 +4202 +4203 +4204 +4205 +4206 +4207 +4208 +4209 +421 +4210 +4211 +4212 +4213 +4214 +4215 +4216 +4217 +4218 +4219 +422 +4220 +4221 +4222 +4223 +4224 +4225 +4226 +4227 +4228 +4229 +423 +4230 +4231 +4232 +4233 +4234 +4235 +4236 +4237 +4238 +4239 +424 +4240 +4241 +4242 +4243 +4244 +4245 +4246 +4247 +4248 +4249 +425 +4250 +4251 +4252 +4253 +4254 +4255 +4256 +4257 +4258 +4259 +426 +4260 +4261 +4262 +4263 +4264 +4265 +4266 +4267 +4268 +4269 +427 +4270 +4271 +4272 +4273 +4274 +4275 +4276 +4277 +4278 +4279 +428 +4280 +4281 +4282 +4283 +4284 +4285 +4286 +4287 +4288 +4289 +429 +4290 +4291 +4292 +4293 +4294 +4295 +4296 +4297 +4298 +4299 +43 +430 +4300 +4301 +4302 +4303 +4304 +4305 +4306 +4307 +4308 +4309 +431 +4310 +4311 +4312 +4313 +4314 +4315 +4316 +4317 +4318 +4319 +432 +4320 +4321 +4322 +4323 +4324 +4325 +4326 +4327 +4328 +4329 +433 +4330 +4331 +4332 +4333 +4334 +4335 +4336 +4337 +4338 +4339 +434 +4340 +4341 +4342 +4343 +4344 +4345 +4346 +4347 +4348 +4349 +435 +4350 +4351 +4352 +4353 +4354 +4355 +4356 +4357 +4358 +4359 +436 +4360 +4361 +4362 +4363 +4364 +4365 +4366 +4367 +4368 +4369 +437 +4370 +4371 +4372 +4373 +4374 +4375 +4376 +4377 +4378 +4379 +438 +4380 +4381 +4382 +4383 +4384 +4385 +4386 +4387 +4388 +4389 +439 +4390 +4391 +4392 +4393 +4394 +4395 +4396 +4397 +4398 +4399 +44 +440 +4400 +4401 +4402 +4403 +4404 +4405 +4406 +4407 +4408 +4409 +441 +4410 +4411 +4412 +4413 +4414 +4415 +4416 +4417 +4418 +4419 +442 +4420 +4421 +4422 +4423 +4424 +4425 +4426 +4427 +4428 +4429 +443 +4430 +4431 +4432 +4433 +4434 +4435 +4436 +4437 +4438 +4439 +444 +4440 +4441 +4442 +4443 +4444 +4445 +4446 +4447 +4448 +4449 +445 +4450 +4451 +4452 +4453 +4454 +4455 +4456 +4457 +4458 +4459 +446 +4460 +4461 +4462 +4463 +4464 +4465 +4466 +4467 +4468 +4469 +447 +4470 +4471 +4472 +4473 +4474 +4475 +4476 +4477 +4478 +4479 +448 +4480 +4481 +4482 +4483 +4484 +4485 +4486 +4487 +4488 +4489 +449 +4490 +4491 +4492 +4493 +4494 +4495 +4496 +4497 +4498 +4499 +45 +450 +4500 +4501 +4502 +4503 +4504 +4505 +4506 +4507 +4508 +4509 +451 +4510 +4511 +4512 +4513 +4514 +4515 +4516 +4517 +4518 +4519 +452 +4520 +4521 +4522 +4523 +4524 +4525 +4526 +4527 +4528 +4529 +453 +4530 +4531 +4532 +4533 +4534 +4535 +4536 +4537 +4538 +4539 +454 +4540 +4541 +4542 +4543 +4544 +4545 +4546 +4547 +4548 +4549 +455 +4550 +4551 +4552 +4553 +4554 +4555 +4556 +4557 +4558 +4559 +456 +4560 +4561 +4562 +4563 +4564 +4565 +4566 +4567 +4568 +4569 +457 +4570 +4571 +4572 +4573 +4574 +4575 +4576 +4577 +4578 +4579 +458 +4580 +4581 +4582 +4583 +4584 +4585 +4586 +4587 +4588 +4589 +459 +4590 +4591 +4592 +4593 +4594 +4595 +4596 +4597 +4598 +4599 +46 +460 +4600 +4601 +4602 +4603 +4604 +4605 +4606 +4607 +4608 +4609 +461 +4610 +4611 +4612 +4613 +4614 +4615 +4616 +4617 +4618 +4619 +462 +4620 +4621 +4622 +4623 +4624 +4625 +4626 +4627 +4628 +4629 +463 +4630 +4631 +4632 +4633 +4634 +4635 +4636 +4637 +4638 +4639 +464 +4640 +4641 +4642 +4643 +4644 +4645 +4646 +4647 +4648 +4649 +465 +4650 +4651 +4652 +4653 +4654 +4655 +4656 +4657 +4658 +4659 +466 +4660 +4661 +4662 +4663 +4664 +4665 +4666 +4667 +4668 +4669 +467 +4670 +4671 +4672 +4673 +4674 +4675 +4676 +4677 +4678 +4679 +468 +4680 +4681 +4682 +4683 +4684 +4685 +4686 +4687 +4688 +4689 +469 +4690 +4691 +4692 +4693 +4694 +4695 +4696 +4697 +4698 +4699 +47 +470 +4700 +4701 +4702 +4703 +4704 +4705 +4706 +4707 +4708 +4709 +471 +4710 +4711 +4712 +4713 +4714 +4715 +4716 +4717 +4718 +4719 +472 +4720 +4721 +4722 +4723 +4724 +4725 +4726 +4727 +4728 +4729 +473 +4730 +4731 +4732 +4733 +4734 +4735 +4736 +4737 +4738 +4739 +474 +4740 +4741 +4742 +4743 +4744 +4745 +4746 +4747 +4748 +4749 +475 +4750 +4751 +4752 +4753 +4754 +4755 +4756 +4757 +4758 +4759 +476 +4760 +4761 +4762 +4763 +4764 +4765 +4766 +4767 +4768 +4769 +477 +4770 +4771 +4772 +4773 +4774 +4775 +4776 +4777 +4778 +4779 +478 +4780 +4781 +4782 +4783 +4784 +4785 +4786 +4787 +4788 +4789 +479 +4790 +4791 +4792 +4793 +4794 +4795 +4796 +4797 +4798 +4799 +48 +480 +4800 +4801 +4802 +4803 +4804 +4805 +4806 +4807 +4808 +4809 +481 +4810 +4811 +4812 +4813 +4814 +4815 +4816 +4817 +4818 +4819 +482 +4820 +4821 +4822 +4823 +4824 +4825 +4826 +4827 +4828 +4829 +483 +4830 +4831 +4832 +4833 +4834 +4835 +4836 +4837 +4838 +4839 +484 +4840 +4841 +4842 +4843 +4844 +4845 +4846 +4847 +4848 +4849 +485 +4850 +4851 +4852 +4853 +4854 +4855 +4856 +4857 +4858 +4859 +486 +4860 +4861 +4862 +4863 +4864 +4865 +4866 +4867 +4868 +4869 +487 +4870 +4871 +4872 +4873 +4874 +4875 +4876 +4877 +4878 +4879 +488 +4880 +4881 +4882 +4883 +4884 +4885 +4886 +4887 +4888 +4889 +489 +4890 +4891 +4892 +4893 +4894 +4895 +4896 +4897 +4898 +4899 +49 +490 +4900 +4901 +4902 +4903 +4904 +4905 +4906 +4907 +4908 +4909 +491 +4910 +4911 +4912 +4913 +4914 +4915 +4916 +4917 +4918 +4919 +492 +4920 +4921 +4922 +4923 +4924 +4925 +4926 +4927 +4928 +4929 +493 +4930 +4931 +4932 +4933 +4934 +4935 +4936 +4937 +4938 +4939 +494 +4940 +4941 +4942 +4943 +4944 +4945 +4946 +4947 +4948 +4949 +495 +4950 +4951 +4952 +4953 +4954 +4955 +4956 +4957 +4958 +4959 +496 +4960 +4961 +4962 +4963 +4964 +4965 +4966 +4967 +4968 +4969 +497 +4970 +4971 +4972 +4973 +4974 +4975 +4976 +4977 +4978 +4979 +498 +4980 +4981 +4982 +4983 +4984 +4985 +4986 +4987 +4988 +4989 +499 +4990 +4991 +4992 +4993 +4994 +4995 +4996 +4997 +4998 +4999 +5 +50 +500 +5000 +5001 +5002 +5003 +5004 +5005 +5006 +5007 +5008 +5009 +501 +5010 +5011 +5012 +5013 +5014 +5015 +5016 +5017 +5018 +5019 +502 +5020 +5021 +5022 +5023 +5024 +5025 +5026 +5027 +5028 +5029 +503 +5030 +5031 +5032 +5033 +5034 +5035 +5036 +5037 +5038 +5039 +504 +5040 +5041 +5042 +5043 +5044 +5045 +5046 +5047 +5048 +5049 +505 +5050 +5051 +5052 +5053 +5054 +5055 +5056 +5057 +5058 +5059 +506 +5060 +5061 +5062 +5063 +5064 +5065 +5066 +5067 +5068 +5069 +507 +5070 +5071 +5072 +5073 +5074 +5075 +5076 +5077 +5078 +5079 +508 +5080 +5081 +5082 +5083 +5084 +5085 +5086 +5087 +5088 +5089 +509 +5090 +5091 +5092 +5093 +5094 +5095 +5096 +5097 +5098 +5099 +51 +510 +5100 +5101 +5102 +5103 +5104 +5105 +5106 +5107 +5108 +5109 +511 +5110 +5111 +5112 +5113 +5114 +5115 +5116 +5117 +5118 +5119 +512 +5120 +5121 +5122 +5123 +5124 +5125 +5126 +5127 +5128 +5129 +513 +5130 +5131 +5132 +5133 +5134 +5135 +5136 +5137 +5138 +5139 +514 +5140 +5141 +5142 +5143 +5144 +5145 +5146 +5147 +5148 +5149 +515 +5150 +5151 +5152 +5153 +5154 +5155 +5156 +5157 +5158 +5159 +516 +5160 +5161 +5162 +5163 +5164 +5165 +5166 +5167 +5168 +5169 +517 +5170 +5171 +5172 +5173 +5174 +5175 +5176 +5177 +5178 +5179 +518 +5180 +5181 +5182 +5183 +5184 +5185 +5186 +5187 +5188 +5189 +519 +5190 +5191 +5192 +5193 +5194 +5195 +5196 +5197 +5198 +5199 +52 +520 +5200 +5201 +5202 +5203 +5204 +5205 +5206 +5207 +5208 +5209 +521 +5210 +5211 +5212 +5213 +5214 +5215 +5216 +5217 +5218 +5219 +522 +5220 +5221 +5222 +5223 +5224 +5225 +5226 +5227 +5228 +5229 +523 +5230 +5231 +5232 +5233 +5234 +5235 +5236 +5237 +5238 +5239 +524 +5240 +5241 +5242 +5243 +5244 +5245 +5246 +5247 +5248 +5249 +525 +5250 +5251 +5252 +5253 +5254 +5255 +5256 +5257 +5258 +5259 +526 +5260 +5261 +5262 +5263 +5264 +5265 +5266 +5267 +5268 +5269 +527 +5270 +5271 +5272 +5273 +5274 +5275 +5276 +5277 +5278 +5279 +528 +5280 +5281 +5282 +5283 +5284 +5285 +5286 +5287 +5288 +5289 +529 +5290 +5291 +5292 +5293 +5294 +5295 +5296 +5297 +5298 +5299 +53 +530 +5300 +5301 +5302 +5303 +5304 +5305 +5306 +5307 +5308 +5309 +531 +5310 +5311 +5312 +5313 +5314 +5315 +5316 +5317 +5318 +5319 +532 +5320 +5321 +5322 +5323 +5324 +5325 +5326 +5327 +5328 +5329 +533 +5330 +5331 +5332 +5333 +5334 +5335 +5336 +5337 +5338 +5339 +534 +5340 +5341 +5342 +5343 +5344 +5345 +5346 +5347 +5348 +5349 +535 +5350 +5351 +5352 +5353 +5354 +5355 +5356 +5357 +5358 +5359 +536 +5360 +5361 +5362 +5363 +5364 +5365 +5366 +5367 +5368 +5369 +537 +5370 +5371 +5372 +5373 +5374 +5375 +5376 +5377 +5378 +5379 +538 +5380 +5381 +5382 +5383 +5384 +5385 +5386 +5387 +5388 +5389 +539 +5390 +5391 +5392 +5393 +5394 +5395 +5396 +5397 +5398 +5399 +54 +540 +5400 +5401 +5402 +5403 +5404 +5405 +5406 +5407 +5408 +5409 +541 +5410 +5411 +5412 +5413 +5414 +5415 +5416 +5417 +5418 +5419 +542 +5420 +5421 +5422 +5423 +5424 +5425 +5426 +5427 +5428 +5429 +543 +5430 +5431 +5432 +5433 +5434 +5435 +5436 +5437 +5438 +5439 +544 +5440 +5441 +5442 +5443 +5444 +5445 +5446 +5447 +5448 +5449 +545 +5450 +5451 +5452 +5453 +5454 +5455 +5456 +5457 +5458 +5459 +546 +5460 +5461 +5462 +5463 +5464 +5465 +5466 +5467 +5468 +5469 +547 +5470 +5471 +5472 +5473 +5474 +5475 +5476 +5477 +5478 +5479 +548 +5480 +5481 +5482 +5483 +5484 +5485 +5486 +5487 +5488 +5489 +549 +5490 +5491 +5492 +5493 +5494 +5495 +5496 +5497 +5498 +5499 +55 +550 +5500 +5501 +5502 +5503 +5504 +5505 +5506 +5507 +5508 +5509 +551 +5510 +5511 +5512 +5513 +5514 +5515 +5516 +5517 +5518 +5519 +552 +5520 +5521 +5522 +5523 +5524 +5525 +5526 +5527 +5528 +5529 +553 +5530 +5531 +5532 +5533 +5534 +5535 +5536 +5537 +5538 +5539 +554 +5540 +5541 +5542 +5543 +5544 +5545 +5546 +5547 +5548 +5549 +555 +5550 +5551 +5552 +5553 +5554 +5555 +5556 +5557 +5558 +5559 +556 +5560 +5561 +5562 +5563 +5564 +5565 +5566 +5567 +5568 +5569 +557 +5570 +5571 +5572 +5573 +5574 +5575 +5576 +5577 +5578 +5579 +558 +5580 +5581 +5582 +5583 +5584 +5585 +5586 +5587 +5588 +5589 +559 +5590 +5591 +5592 +5593 +5594 +5595 +5596 +5597 +5598 +5599 +56 +560 +5600 +5601 +5602 +5603 +5604 +5605 +5606 +5607 +5608 +5609 +561 +5610 +5611 +5612 +5613 +5614 +5615 +5616 +5617 +5618 +5619 +562 +5620 +5621 +5622 +5623 +5624 +5625 +5626 +5627 +5628 +5629 +563 +5630 +5631 +5632 +5633 +5634 +5635 +5636 +5637 +5638 +5639 +564 +5640 +5641 +5642 +5643 +5644 +5645 +5646 +5647 +5648 +5649 +565 +5650 +5651 +5652 +5653 +5654 +5655 +5656 +5657 +5658 +5659 +566 +5660 +5661 +5662 +5663 +5664 +5665 +5666 +5667 +5668 +5669 +567 +5670 +5671 +5672 +5673 +5674 +5675 +5676 +5677 +5678 +5679 +568 +5680 +5681 +5682 +5683 +5684 +5685 +5686 +5687 +5688 +5689 +569 +5690 +5691 +5692 +5693 +5694 +5695 +5696 +5697 +5698 +5699 +57 +570 +5700 +5701 +5702 +5703 +5704 +5705 +5706 +5707 +5708 +5709 +571 +5710 +5711 +5712 +5713 +5714 +5715 +5716 +5717 +5718 +5719 +572 +5720 +5721 +5722 +5723 +5724 +5725 +5726 +5727 +5728 +5729 +573 +5730 +5731 +5732 +5733 +5734 +5735 +5736 +5737 +5738 +5739 +574 +5740 +5741 +5742 +5743 +5744 +5745 +5746 +5747 +5748 +5749 +575 +5750 +5751 +5752 +5753 +5754 +5755 +5756 +5757 +5758 +5759 +576 +5760 +5761 +5762 +5763 +5764 +5765 +5766 +5767 +5768 +5769 +577 +5770 +5771 +5772 +5773 +5774 +5775 +5776 +5777 +5778 +5779 +578 +5780 +5781 +5782 +5783 +5784 +5785 +5786 +5787 +5788 +5789 +579 +5790 +5791 +5792 +5793 +5794 +5795 +5796 +5797 +5798 +5799 +58 +580 +5800 +5801 +5802 +5803 +5804 +5805 +5806 +5807 +5808 +5809 +581 +5810 +5811 +5812 +5813 +5814 +5815 +5816 +5817 +5818 +5819 +582 +5820 +5821 +5822 +5823 +5824 +5825 +5826 +5827 +5828 +5829 +583 +5830 +5831 +5832 +5833 +5834 +5835 +5836 +5837 +5838 +5839 +584 +5840 +5841 +5842 +5843 +5844 +5845 +5846 +5847 +5848 +5849 +585 +5850 +5851 +5852 +5853 +5854 +5855 +5856 +5857 +5858 +5859 +586 +5860 +5861 +5862 +5863 +5864 +5865 +5866 +5867 +5868 +5869 +587 +5870 +5871 +5872 +5873 +5874 +5875 +5876 +5877 +5878 +5879 +588 +5880 +5881 +5882 +5883 +5884 +5885 +5886 +5887 +5888 +5889 +589 +5890 +5891 +5892 +5893 +5894 +5895 +5896 +5897 +5898 +5899 +59 +590 +5900 +5901 +5902 +5903 +5904 +5905 +5906 +5907 +5908 +5909 +591 +5910 +5911 +5912 +5913 +5914 +5915 +5916 +5917 +5918 +5919 +592 +5920 +5921 +5922 +5923 +5924 +5925 +5926 +5927 +5928 +5929 +593 +5930 +5931 +5932 +5933 +5934 +5935 +5936 +5937 +5938 +5939 +594 +5940 +5941 +5942 +5943 +5944 +5945 +5946 +5947 +5948 +5949 +595 +5950 +5951 +5952 +5953 +5954 +5955 +5956 +5957 +5958 +5959 +596 +5960 +5961 +5962 +5963 +5964 +5965 +5966 +5967 +5968 +5969 +597 +5970 +5971 +5972 +5973 +5974 +5975 +5976 +5977 +5978 +5979 +598 +5980 +5981 +5982 +5983 +5984 +5985 +5986 +5987 +5988 +5989 +599 +5990 +5991 +5992 +5993 +5994 +5995 +5996 +5997 +5998 +5999 +6 +60 +600 +6000 +6001 +6002 +6003 +6004 +6005 +6006 +6007 +6008 +6009 +601 +6010 +6011 +6012 +6013 +6014 +6015 +6016 +6017 +6018 +6019 +602 +6020 +6021 +6022 +6023 +6024 +6025 +6026 +6027 +6028 +6029 +603 +6030 +6031 +6032 +6033 +6034 +6035 +6036 +6037 +6038 +6039 +604 +6040 +6041 +6042 +6043 +6044 +6045 +6046 +6047 +6048 +6049 +605 +6050 +6051 +6052 +6053 +6054 +6055 +6056 +6057 +6058 +6059 +606 +6060 +6061 +6062 +6063 +6064 +6065 +6066 +6067 +6068 +6069 +607 +6070 +6071 +6072 +6073 +6074 +6075 +6076 +6077 +6078 +6079 +608 +6080 +6081 +6082 +6083 +6084 +6085 +6086 +6087 +6088 +6089 +609 +6090 +6091 +6092 +6093 +6094 +6095 +6096 +6097 +6098 +6099 +61 +610 +6100 +6101 +6102 +6103 +6104 +6105 +6106 +6107 +6108 +6109 +611 +6110 +6111 +6112 +6113 +6114 +6115 +6116 +6117 +6118 +6119 +612 +6120 +6121 +6122 +6123 +6124 +6125 +6126 +6127 +6128 +6129 +613 +6130 +6131 +6132 +6133 +6134 +6135 +6136 +6137 +6138 +6139 +614 +6140 +6141 +6142 +6143 +6144 +6145 +6146 +6147 +6148 +6149 +615 +6150 +6151 +6152 +6153 +6154 +6155 +6156 +6157 +6158 +6159 +616 +6160 +6161 +6162 +6163 +6164 +6165 +6166 +6167 +6168 +6169 +617 +6170 +6171 +6172 +6173 +6174 +6175 +6176 +6177 +6178 +6179 +618 +6180 +6181 +6182 +6183 +6184 +6185 +6186 +6187 +6188 +6189 +619 +6190 +6191 +6192 +6193 +6194 +6195 +6196 +6197 +6198 +6199 +62 +620 +6200 +6201 +6202 +6203 +6204 +6205 +6206 +6207 +6208 +6209 +621 +6210 +6211 +6212 +6213 +6214 +6215 +6216 +6217 +6218 +6219 +622 +6220 +6221 +6222 +6223 +6224 +6225 +6226 +6227 +6228 +6229 +623 +6230 +6231 +6232 +6233 +6234 +6235 +6236 +6237 +6238 +6239 +624 +6240 +6241 +6242 +6243 +6244 +6245 +6246 +6247 +6248 +6249 +625 +6250 +6251 +6252 +6253 +6254 +6255 +6256 +6257 +6258 +6259 +626 +6260 +6261 +6262 +6263 +6264 +6265 +6266 +6267 +6268 +6269 +627 +6270 +6271 +6272 +6273 +6274 +6275 +6276 +6277 +6278 +6279 +628 +6280 +6281 +6282 +6283 +6284 +6285 +6286 +6287 +6288 +6289 +629 +6290 +6291 +6292 +6293 +6294 +6295 +6296 +6297 +6298 +6299 +63 +630 +6300 +6301 +6302 +6303 +6304 +6305 +6306 +6307 +6308 +6309 +631 +6310 +6311 +6312 +6313 +6314 +6315 +6316 +6317 +6318 +6319 +632 +6320 +6321 +6322 +6323 +6324 +6325 +6326 +6327 +6328 +6329 +633 +6330 +6331 +6332 +6333 +6334 +6335 +6336 +6337 +6338 +6339 +634 +6340 +6341 +6342 +6343 +6344 +6345 +6346 +6347 +6348 +6349 +635 +6350 +6351 +6352 +6353 +6354 +6355 +6356 +6357 +6358 +6359 +636 +6360 +6361 +6362 +6363 +6364 +6365 +6366 +6367 +6368 +6369 +637 +6370 +6371 +6372 +6373 +6374 +6375 +6376 +6377 +6378 +6379 +638 +6380 +6381 +6382 +6383 +6384 +6385 +6386 +6387 +6388 +6389 +639 +6390 +6391 +6392 +6393 +6394 +6395 +6396 +6397 +6398 +6399 +64 +640 +6400 +6401 +6402 +6403 +6404 +6405 +6406 +6407 +6408 +6409 +641 +6410 +6411 +6412 +6413 +6414 +6415 +6416 +6417 +6418 +6419 +642 +6420 +6421 +6422 +6423 +6424 +6425 +6426 +6427 +6428 +6429 +643 +6430 +6431 +6432 +6433 +6434 +6435 +6436 +6437 +6438 +6439 +644 +6440 +6441 +6442 +6443 +6444 +6445 +6446 +6447 +6448 +6449 +645 +6450 +6451 +6452 +6453 +6454 +6455 +6456 +6457 +6458 +6459 +646 +6460 +6461 +6462 +6463 +6464 +6465 +6466 +6467 +6468 +6469 +647 +6470 +6471 +6472 +6473 +6474 +6475 +6476 +6477 +6478 +6479 +648 +6480 +6481 +6482 +6483 +6484 +6485 +6486 +6487 +6488 +6489 +649 +6490 +6491 +6492 +6493 +6494 +6495 +6496 +6497 +6498 +6499 +65 +650 +6500 +6501 +6502 +6503 +6504 +6505 +6506 +6507 +6508 +6509 +651 +6510 +6511 +6512 +6513 +6514 +6515 +6516 +6517 +6518 +6519 +652 +6520 +6521 +6522 +6523 +6524 +6525 +6526 +6527 +6528 +6529 +653 +6530 +6531 +6532 +6533 +6534 +6535 +6536 +6537 +6538 +6539 +654 +6540 +6541 +6542 +6543 +6544 +6545 +6546 +6547 +6548 +6549 +655 +6550 +6551 +6552 +6553 +6554 +6555 +6556 +6557 +6558 +6559 +656 +6560 +6561 +6562 +6563 +6564 +6565 +6566 +6567 +6568 +6569 +657 +6570 +6571 +6572 +6573 +6574 +6575 +6576 +6577 +6578 +6579 +658 +6580 +6581 +6582 +6583 +6584 +6585 +6586 +6587 +6588 +6589 +659 +6590 +6591 +6592 +6593 +6594 +6595 +6596 +6597 +6598 +6599 +66 +660 +6600 +6601 +6602 +6603 +6604 +6605 +6606 +6607 +6608 +6609 +661 +6610 +6611 +6612 +6613 +6614 +6615 +6616 +6617 +6618 +6619 +662 +6620 +6621 +6622 +6623 +6624 +6625 +6626 +6627 +6628 +6629 +663 +6630 +6631 +6632 +6633 +6634 +6635 +6636 +6637 +6638 +6639 +664 +6640 +6641 +6642 +6643 +6644 +6645 +6646 +6647 +6648 +6649 +665 +6650 +6651 +6652 +6653 +6654 +6655 +6656 +6657 +6658 +6659 +666 +6660 +6661 +6662 +6663 +6664 +6665 +6666 +6667 +6668 +6669 +667 +6670 +6671 +6672 +6673 +6674 +6675 +6676 +6677 +6678 +6679 +668 +6680 +6681 +6682 +6683 +6684 +6685 +6686 +6687 +6688 +6689 +669 +6690 +6691 +6692 +6693 +6694 +6695 +6696 +6697 +6698 +6699 +67 +670 +6700 +6701 +6702 +6703 +6704 +6705 +6706 +6707 +6708 +6709 +671 +6710 +6711 +6712 +6713 +6714 +6715 +6716 +6717 +6718 +6719 +672 +6720 +6721 +6722 +6723 +6724 +6725 +6726 +6727 +6728 +6729 +673 +6730 +6731 +6732 +6733 +6734 +6735 +6736 +6737 +6738 +6739 +674 +6740 +6741 +6742 +6743 +6744 +6745 +6746 +6747 +6748 +6749 +675 +6750 +6751 +6752 +6753 +6754 +6755 +6756 +6757 +6758 +6759 +676 +6760 +6761 +6762 +6763 +6764 +6765 +6766 +6767 +6768 +6769 +677 +6770 +6771 +6772 +6773 +6774 +6775 +6776 +6777 +6778 +6779 +678 +6780 +6781 +6782 +6783 +6784 +6785 +6786 +6787 +6788 +6789 +679 +6790 +6791 +6792 +6793 +6794 +6795 +6796 +6797 +6798 +6799 +68 +680 +6800 +6801 +6802 +6803 +6804 +6805 +6806 +6807 +6808 +6809 +681 +6810 +6811 +6812 +6813 +6814 +6815 +6816 +6817 +6818 +6819 +682 +6820 +6821 +6822 +6823 +6824 +6825 +6826 +6827 +6828 +6829 +683 +6830 +6831 +6832 +6833 +6834 +6835 +6836 +6837 +6838 +6839 +684 +6840 +6841 +6842 +6843 +6844 +6845 +6846 +6847 +6848 +6849 +685 +6850 +6851 +6852 +6853 +6854 +6855 +6856 +6857 +6858 +6859 +686 +6860 +6861 +6862 +6863 +6864 +6865 +6866 +6867 +6868 +6869 +687 +6870 +6871 +6872 +6873 +6874 +6875 +6876 +6877 +6878 +6879 +688 +6880 +6881 +6882 +6883 +6884 +6885 +6886 +6887 +6888 +6889 +689 +6890 +6891 +6892 +6893 +6894 +6895 +6896 +6897 +6898 +6899 +69 +690 +6900 +6901 +6902 +6903 +6904 +6905 +6906 +6907 +6908 +6909 +691 +6910 +6911 +6912 +6913 +6914 +6915 +6916 +6917 +6918 +6919 +692 +6920 +6921 +6922 +6923 +6924 +6925 +6926 +6927 +6928 +6929 +693 +6930 +6931 +6932 +6933 +6934 +6935 +6936 +6937 +6938 +6939 +694 +6940 +6941 +6942 +6943 +6944 +6945 +6946 +6947 +6948 +6949 +695 +6950 +6951 +6952 +6953 +6954 +6955 +6956 +6957 +6958 +6959 +696 +6960 +6961 +6962 +6963 +6964 +6965 +6966 +6967 +6968 +6969 +697 +6970 +6971 +6972 +6973 +6974 +6975 +6976 +6977 +6978 +6979 +698 +6980 +6981 +6982 +6983 +6984 +6985 +6986 +6987 +6988 +6989 +699 +6990 +6991 +6992 +6993 +6994 +6995 +6996 +6997 +6998 +6999 +7 +70 +700 +7000 +7001 +7002 +7003 +7004 +7005 +7006 +7007 +7008 +7009 +701 +7010 +7011 +7012 +7013 +7014 +7015 +7016 +7017 +7018 +7019 +702 +7020 +7021 +7022 +7023 +7024 +7025 +7026 +7027 +7028 +7029 +703 +7030 +7031 +7032 +7033 +7034 +7035 +7036 +7037 +7038 +7039 +704 +7040 +7041 +7042 +7043 +7044 +7045 +7046 +7047 +7048 +7049 +705 +7050 +7051 +7052 +7053 +7054 +7055 +7056 +7057 +7058 +7059 +706 +7060 +7061 +7062 +7063 +7064 +7065 +7066 +7067 +7068 +7069 +707 +7070 +7071 +7072 +7073 +7074 +7075 +7076 +7077 +7078 +7079 +708 +7080 +7081 +7082 +7083 +7084 +7085 +7086 +7087 +7088 +7089 +709 +7090 +7091 +7092 +7093 +7094 +7095 +7096 +7097 +7098 +7099 +71 +710 +7100 +7101 +7102 +7103 +7104 +7105 +7106 +7107 +7108 +7109 +711 +7110 +7111 +7112 +7113 +7114 +7115 +7116 +7117 +7118 +7119 +712 +7120 +7121 +7122 +7123 +7124 +7125 +7126 +7127 +7128 +7129 +713 +7130 +7131 +7132 +7133 +7134 +7135 +7136 +7137 +7138 +7139 +714 +7140 +7141 +7142 +7143 +7144 +7145 +7146 +7147 +7148 +7149 +715 +7150 +7151 +7152 +7153 +7154 +7155 +7156 +7157 +7158 +7159 +716 +7160 +7161 +7162 +7163 +7164 +7165 +7166 +7167 +7168 +7169 +717 +7170 +7171 +7172 +7173 +7174 +7175 +7176 +7177 +7178 +7179 +718 +7180 +7181 +7182 +7183 +7184 +7185 +7186 +7187 +7188 +7189 +719 +7190 +7191 +7192 +7193 +7194 +7195 +7196 +7197 +7198 +7199 +72 +720 +7200 +7201 +7202 +7203 +7204 +7205 +7206 +7207 +7208 +7209 +721 +7210 +7211 +7212 +7213 +7214 +7215 +7216 +7217 +7218 +7219 +722 +7220 +7221 +7222 +7223 +7224 +7225 +7226 +7227 +7228 +7229 +723 +7230 +7231 +7232 +7233 +7234 +7235 +7236 +7237 +7238 +7239 +724 +7240 +7241 +7242 +7243 +7244 +7245 +7246 +7247 +7248 +7249 +725 +7250 +7251 +7252 +7253 +7254 +7255 +7256 +7257 +7258 +7259 +726 +7260 +7261 +7262 +7263 +7264 +7265 +7266 +7267 +7268 +7269 +727 +7270 +7271 +7272 +7273 +7274 +7275 +7276 +7277 +7278 +7279 +728 +7280 +7281 +7282 +7283 +7284 +7285 +7286 +7287 +7288 +7289 +729 +7290 +7291 +7292 +7293 +7294 +7295 +7296 +7297 +7298 +7299 +73 +730 +7300 +7301 +7302 +7303 +7304 +7305 +7306 +7307 +7308 +7309 +731 +7310 +7311 +7312 +7313 +7314 +7315 +7316 +7317 +7318 +7319 +732 +7320 +7321 +7322 +7323 +7324 +7325 +7326 +7327 +7328 +7329 +733 +7330 +7331 +7332 +7333 +7334 +7335 +7336 +7337 +7338 +7339 +734 +7340 +7341 +7342 +7343 +7344 +7345 +7346 +7347 +7348 +7349 +735 +7350 +7351 +7352 +7353 +7354 +7355 +7356 +7357 +7358 +7359 +736 +7360 +7361 +7362 +7363 +7364 +7365 +7366 +7367 +7368 +7369 +737 +7370 +7371 +7372 +7373 +7374 +7375 +7376 +7377 +7378 +7379 +738 +7380 +7381 +7382 +7383 +7384 +7385 +7386 +7387 +7388 +7389 +739 +7390 +7391 +7392 +7393 +7394 +7395 +7396 +7397 +7398 +7399 +74 +740 +7400 +7401 +7402 +7403 +7404 +7405 +7406 +7407 +7408 +7409 +741 +7410 +7411 +7412 +7413 +7414 +7415 +7416 +7417 +7418 +7419 +742 +7420 +7421 +7422 +7423 +7424 +7425 +7426 +7427 +7428 +7429 +743 +7430 +7431 +7432 +7433 +7434 +7435 +7436 +7437 +7438 +7439 +744 +7440 +7441 +7442 +7443 +7444 +7445 +7446 +7447 +7448 +7449 +745 +7450 +7451 +7452 +7453 +7454 +7455 +7456 +7457 +7458 +7459 +746 +7460 +7461 +7462 +7463 +7464 +7465 +7466 +7467 +7468 +7469 +747 +7470 +7471 +7472 +7473 +7474 +7475 +7476 +7477 +7478 +7479 +748 +7480 +7481 +7482 +7483 +7484 +7485 +7486 +7487 +7488 +7489 +749 +7490 +7491 +7492 +7493 +7494 +7495 +7496 +7497 +7498 +7499 +75 +750 +7500 +7501 +7502 +7503 +7504 +7505 +7506 +7507 +7508 +7509 +751 +7510 +7511 +7512 +7513 +7514 +7515 +7516 +7517 +7518 +7519 +752 +7520 +7521 +7522 +7523 +7524 +7525 +7526 +7527 +7528 +7529 +753 +7530 +7531 +7532 +7533 +7534 +7535 +7536 +7537 +7538 +7539 +754 +7540 +7541 +7542 +7543 +7544 +7545 +7546 +7547 +7548 +7549 +755 +7550 +7551 +7552 +7553 +7554 +7555 +7556 +7557 +7558 +7559 +756 +7560 +7561 +7562 +7563 +7564 +7565 +7566 +7567 +7568 +7569 +757 +7570 +7571 +7572 +7573 +7574 +7575 +7576 +7577 +7578 +7579 +758 +7580 +7581 +7582 +7583 +7584 +7585 +7586 +7587 +7588 +7589 +759 +7590 +7591 +7592 +7593 +7594 +7595 +7596 +7597 +7598 +7599 +76 +760 +7600 +7601 +7602 +7603 +7604 +7605 +7606 +7607 +7608 +7609 +761 +7610 +7611 +7612 +7613 +7614 +7615 +7616 +7617 +7618 +7619 +762 +7620 +7621 +7622 +7623 +7624 +7625 +7626 +7627 +7628 +7629 +763 +7630 +7631 +7632 +7633 +7634 +7635 +7636 +7637 +7638 +7639 +764 +7640 +7641 +7642 +7643 +7644 +7645 +7646 +7647 +7648 +7649 +765 +7650 +7651 +7652 +7653 +7654 +7655 +7656 +7657 +7658 +7659 +766 +7660 +7661 +7662 +7663 +7664 +7665 +7666 +7667 +7668 +7669 +767 +7670 +7671 +7672 +7673 +7674 +7675 +7676 +7677 +7678 +7679 +768 +7680 +7681 +7682 +7683 +7684 +7685 +7686 +7687 +7688 +7689 +769 +7690 +7691 +7692 +7693 +7694 +7695 +7696 +7697 +7698 +7699 +77 +770 +7700 +7701 +7702 +7703 +7704 +7705 +7706 +7707 +7708 +7709 +771 +7710 +7711 +7712 +7713 +7714 +7715 +7716 +7717 +7718 +7719 +772 +7720 +7721 +7722 +7723 +7724 +7725 +7726 +7727 +7728 +7729 +773 +7730 +7731 +7732 +7733 +7734 +7735 +7736 +7737 +7738 +7739 +774 +7740 +7741 +7742 +7743 +7744 +7745 +7746 +7747 +7748 +7749 +775 +7750 +7751 +7752 +7753 +7754 +7755 +7756 +7757 +7758 +7759 +776 +7760 +7761 +7762 +7763 +7764 +7765 +7766 +7767 +7768 +7769 +777 +7770 +7771 +7772 +7773 +7774 +7775 +7776 +7777 +7778 +7779 +778 +7780 +7781 +7782 +7783 +7784 +7785 +7786 +7787 +7788 +7789 +779 +7790 +7791 +7792 +7793 +7794 +7795 +7796 +7797 +7798 +7799 +78 +780 +7800 +7801 +7802 +7803 +7804 +7805 +7806 +7807 +7808 +7809 +781 +7810 +7811 +7812 +7813 +7814 +7815 +7816 +7817 +7818 +7819 +782 +7820 +7821 +7822 +7823 +7824 +7825 +7826 +7827 +7828 +7829 +783 +7830 +7831 +7832 +7833 +7834 +7835 +7836 +7837 +7838 +7839 +784 +7840 +7841 +7842 +7843 +7844 +7845 +7846 +7847 +7848 +7849 +785 +7850 +7851 +7852 +7853 +7854 +7855 +7856 +7857 +7858 +7859 +786 +7860 +7861 +7862 +7863 +7864 +7865 +7866 +7867 +7868 +7869 +787 +7870 +7871 +7872 +7873 +7874 +7875 +7876 +7877 +7878 +7879 +788 +7880 +7881 +7882 +7883 +7884 +7885 +7886 +7887 +7888 +7889 +789 +7890 +7891 +7892 +7893 +7894 +7895 +7896 +7897 +7898 +7899 +79 +790 +7900 +7901 +7902 +7903 +7904 +7905 +7906 +7907 +7908 +7909 +791 +7910 +7911 +7912 +7913 +7914 +7915 +7916 +7917 +7918 +7919 +792 +7920 +7921 +7922 +7923 +7924 +7925 +7926 +7927 +7928 +7929 +793 +7930 +7931 +7932 +7933 +7934 +7935 +7936 +7937 +7938 +7939 +794 +7940 +7941 +7942 +7943 +7944 +7945 +7946 +7947 +7948 +7949 +795 +7950 +7951 +7952 +7953 +7954 +7955 +7956 +7957 +7958 +7959 +796 +7960 +7961 +7962 +7963 +7964 +7965 +7966 +7967 +7968 +7969 +797 +7970 +7971 +7972 +7973 +7974 +7975 +7976 +7977 +7978 +7979 +798 +7980 +7981 +7982 +7983 +7984 +7985 +7986 +7987 +7988 +7989 +799 +7990 +7991 +7992 +7993 +7994 +7995 +7996 +7997 +7998 +7999 +8 +80 +800 +8000 +8001 +8002 +8003 +8004 +8005 +8006 +8007 +8008 +8009 +801 +8010 +8011 +8012 +8013 +8014 +8015 +8016 +8017 +8018 +8019 +802 +8020 +8021 +8022 +8023 +8024 +8025 +8026 +8027 +8028 +8029 +803 +8030 +8031 +8032 +8033 +8034 +8035 +8036 +8037 +8038 +8039 +804 +8040 +8041 +8042 +8043 +8044 +8045 +8046 +8047 +8048 +8049 +805 +8050 +8051 +8052 +8053 +8054 +8055 +8056 +8057 +8058 +8059 +806 +8060 +8061 +8062 +8063 +8064 +8065 +8066 +8067 +8068 +8069 +807 +8070 +8071 +8072 +8073 +8074 +8075 +8076 +8077 +8078 +8079 +808 +8080 +8081 +8082 +8083 +8084 +8085 +8086 +8087 +8088 +8089 +809 +8090 +8091 +8092 +8093 +8094 +8095 +8096 +8097 +8098 +8099 +81 +810 +8100 +8101 +8102 +8103 +8104 +8105 +8106 +8107 +8108 +8109 +811 +8110 +8111 +8112 +8113 +8114 +8115 +8116 +8117 +8118 +8119 +812 +8120 +8121 +8122 +8123 +8124 +8125 +8126 +8127 +8128 +8129 +813 +8130 +8131 +8132 +8133 +8134 +8135 +8136 +8137 +8138 +8139 +814 +8140 +8141 +8142 +8143 +8144 +8145 +8146 +8147 +8148 +8149 +815 +8150 +8151 +8152 +8153 +8154 +8155 +8156 +8157 +8158 +8159 +816 +8160 +8161 +8162 +8163 +8164 +8165 +8166 +8167 +8168 +8169 +817 +8170 +8171 +8172 +8173 +8174 +8175 +8176 +8177 +8178 +8179 +818 +8180 +8181 +8182 +8183 +8184 +8185 +8186 +8187 +8188 +8189 +819 +8190 +8191 +8192 +8193 +8194 +8195 +8196 +8197 +8198 +8199 +82 +820 +8200 +8201 +8202 +8203 +8204 +8205 +8206 +8207 +8208 +8209 +821 +8210 +8211 +8212 +8213 +8214 +8215 +8216 +8217 +8218 +8219 +822 +8220 +8221 +8222 +8223 +8224 +8225 +8226 +8227 +8228 +8229 +823 +8230 +8231 +8232 +8233 +8234 +8235 +8236 +8237 +8238 +8239 +824 +8240 +8241 +8242 +8243 +8244 +8245 +8246 +8247 +8248 +8249 +825 +8250 +8251 +8252 +8253 +8254 +8255 +8256 +8257 +8258 +8259 +826 +8260 +8261 +8262 +8263 +8264 +8265 +8266 +8267 +8268 +8269 +827 +8270 +8271 +8272 +8273 +8274 +8275 +8276 +8277 +8278 +8279 +828 +8280 +8281 +8282 +8283 +8284 +8285 +8286 +8287 +8288 +8289 +829 +8290 +8291 +8292 +8293 +8294 +8295 +8296 +8297 +8298 +8299 +83 +830 +8300 +8301 +8302 +8303 +8304 +8305 +8306 +8307 +8308 +8309 +831 +8310 +8311 +8312 +8313 +8314 +8315 +8316 +8317 +8318 +8319 +832 +8320 +8321 +8322 +8323 +8324 +8325 +8326 +8327 +8328 +8329 +833 +8330 +8331 +8332 +8333 +8334 +8335 +8336 +8337 +8338 +8339 +834 +8340 +8341 +8342 +8343 +8344 +8345 +8346 +8347 +8348 +8349 +835 +8350 +8351 +8352 +8353 +8354 +8355 +8356 +8357 +8358 +8359 +836 +8360 +8361 +8362 +8363 +8364 +8365 +8366 +8367 +8368 +8369 +837 +8370 +8371 +8372 +8373 +8374 +8375 +8376 +8377 +8378 +8379 +838 +8380 +8381 +8382 +8383 +8384 +8385 +8386 +8387 +8388 +8389 +839 +8390 +8391 +8392 +8393 +8394 +8395 +8396 +8397 +8398 +8399 +84 +840 +8400 +8401 +8402 +8403 +8404 +8405 +8406 +8407 +8408 +8409 +841 +8410 +8411 +8412 +8413 +8414 +8415 +8416 +8417 +8418 +8419 +842 +8420 +8421 +8422 +8423 +8424 +8425 +8426 +8427 +8428 +8429 +843 +8430 +8431 +8432 +8433 +8434 +8435 +8436 +8437 +8438 +8439 +844 +8440 +8441 +8442 +8443 +8444 +8445 +8446 +8447 +8448 +8449 +845 +8450 +8451 +8452 +8453 +8454 +8455 +8456 +8457 +8458 +8459 +846 +8460 +8461 +8462 +8463 +8464 +8465 +8466 +8467 +8468 +8469 +847 +8470 +8471 +8472 +8473 +8474 +8475 +8476 +8477 +8478 +8479 +848 +8480 +8481 +8482 +8483 +8484 +8485 +8486 +8487 +8488 +8489 +849 +8490 +8491 +8492 +8493 +8494 +8495 +8496 +8497 +8498 +8499 +85 +850 +8500 +8501 +8502 +8503 +8504 +8505 +8506 +8507 +8508 +8509 +851 +8510 +8511 +8512 +8513 +8514 +8515 +8516 +8517 +8518 +8519 +852 +8520 +8521 +8522 +8523 +8524 +8525 +8526 +8527 +8528 +8529 +853 +8530 +8531 +8532 +8533 +8534 +8535 +8536 +8537 +8538 +8539 +854 +8540 +8541 +8542 +8543 +8544 +8545 +8546 +8547 +8548 +8549 +855 +8550 +8551 +8552 +8553 +8554 +8555 +8556 +8557 +8558 +8559 +856 +8560 +8561 +8562 +8563 +8564 +8565 +8566 +8567 +8568 +8569 +857 +8570 +8571 +8572 +8573 +8574 +8575 +8576 +8577 +8578 +8579 +858 +8580 +8581 +8582 +8583 +8584 +8585 +8586 +8587 +8588 +8589 +859 +8590 +8591 +8592 +8593 +8594 +8595 +8596 +8597 +8598 +8599 +86 +860 +8600 +8601 +8602 +8603 +8604 +8605 +8606 +8607 +8608 +8609 +861 +8610 +8611 +8612 +8613 +8614 +8615 +8616 +8617 +8618 +8619 +862 +8620 +8621 +8622 +8623 +8624 +8625 +8626 +8627 +8628 +8629 +863 +8630 +8631 +8632 +8633 +8634 +8635 +8636 +8637 +8638 +8639 +864 +8640 +8641 +8642 +8643 +8644 +8645 +8646 +8647 +8648 +8649 +865 +8650 +8651 +8652 +8653 +8654 +8655 +8656 +8657 +8658 +8659 +866 +8660 +8661 +8662 +8663 +8664 +8665 +8666 +8667 +8668 +8669 +867 +8670 +8671 +8672 +8673 +8674 +8675 +8676 +8677 +8678 +8679 +868 +8680 +8681 +8682 +8683 +8684 +8685 +8686 +8687 +8688 +8689 +869 +8690 +8691 +8692 +8693 +8694 +8695 +8696 +8697 +8698 +8699 +87 +870 +8700 +8701 +8702 +8703 +8704 +8705 +8706 +8707 +8708 +8709 +871 +8710 +8711 +8712 +8713 +8714 +8715 +8716 +8717 +8718 +8719 +872 +8720 +8721 +8722 +8723 +8724 +8725 +8726 +8727 +8728 +8729 +873 +8730 +8731 +8732 +8733 +8734 +8735 +8736 +8737 +8738 +8739 +874 +8740 +8741 +8742 +8743 +8744 +8745 +8746 +8747 +8748 +8749 +875 +8750 +8751 +8752 +8753 +8754 +8755 +8756 +8757 +8758 +8759 +876 +8760 +8761 +8762 +8763 +8764 +8765 +8766 +8767 +8768 +8769 +877 +8770 +8771 +8772 +8773 +8774 +8775 +8776 +8777 +8778 +8779 +878 +8780 +8781 +8782 +8783 +8784 +8785 +8786 +8787 +8788 +8789 +879 +8790 +8791 +8792 +8793 +8794 +8795 +8796 +8797 +8798 +8799 +88 +880 +8800 +8801 +8802 +8803 +8804 +8805 +8806 +8807 +8808 +8809 +881 +8810 +8811 +8812 +8813 +8814 +8815 +8816 +8817 +8818 +8819 +882 +8820 +8821 +8822 +8823 +8824 +8825 +8826 +8827 +8828 +8829 +883 +8830 +8831 +8832 +8833 +8834 +8835 +8836 +8837 +8838 +8839 +884 +8840 +8841 +8842 +8843 +8844 +8845 +8846 +8847 +8848 +8849 +885 +8850 +8851 +8852 +8853 +8854 +8855 +8856 +8857 +8858 +8859 +886 +8860 +8861 +8862 +8863 +8864 +8865 +8866 +8867 +8868 +8869 +887 +8870 +8871 +8872 +8873 +8874 +8875 +8876 +8877 +8878 +8879 +888 +8880 +8881 +8882 +8883 +8884 +8885 +8886 +8887 +8888 +8889 +889 +8890 +8891 +8892 +8893 +8894 +8895 +8896 +8897 +8898 +8899 +89 +890 +8900 +8901 +8902 +8903 +8904 +8905 +8906 +8907 +8908 +8909 +891 +8910 +8911 +8912 +8913 +8914 +8915 +8916 +8917 +8918 +8919 +892 +8920 +8921 +8922 +8923 +8924 +8925 +8926 +8927 +8928 +8929 +893 +8930 +8931 +8932 +8933 +8934 +8935 +8936 +8937 +8938 +8939 +894 +8940 +8941 +8942 +8943 +8944 +8945 +8946 +8947 +8948 +8949 +895 +8950 +8951 +8952 +8953 +8954 +8955 +8956 +8957 +8958 +8959 +896 +8960 +8961 +8962 +8963 +8964 +8965 +8966 +8967 +8968 +8969 +897 +8970 +8971 +8972 +8973 +8974 +8975 +8976 +8977 +8978 +8979 +898 +8980 +8981 +8982 +8983 +8984 +8985 +8986 +8987 +8988 +8989 +899 +8990 +8991 +8992 +8993 +8994 +8995 +8996 +8997 +8998 +8999 +9 +90 +900 +9000 +9001 +9002 +9003 +9004 +9005 +9006 +9007 +9008 +9009 +901 +9010 +9011 +9012 +9013 +9014 +9015 +9016 +9017 +9018 +9019 +902 +9020 +9021 +9022 +9023 +9024 +9025 +9026 +9027 +9028 +9029 +903 +9030 +9031 +9032 +9033 +9034 +9035 +9036 +9037 +9038 +9039 +904 +9040 +9041 +9042 +9043 +9044 +9045 +9046 +9047 +9048 +9049 +905 +9050 +9051 +9052 +9053 +9054 +9055 +9056 +9057 +9058 +9059 +906 +9060 +9061 +9062 +9063 +9064 +9065 +9066 +9067 +9068 +9069 +907 +9070 +9071 +9072 +9073 +9074 +9075 +9076 +9077 +9078 +9079 +908 +9080 +9081 +9082 +9083 +9084 +9085 +9086 +9087 +9088 +9089 +909 +9090 +9091 +9092 +9093 +9094 +9095 +9096 +9097 +9098 +9099 +91 +910 +9100 +9101 +9102 +9103 +9104 +9105 +9106 +9107 +9108 +9109 +911 +9110 +9111 +9112 +9113 +9114 +9115 +9116 +9117 +9118 +9119 +912 +9120 +9121 +9122 +9123 +9124 +9125 +9126 +9127 +9128 +9129 +913 +9130 +9131 +9132 +9133 +9134 +9135 +9136 +9137 +9138 +9139 +914 +9140 +9141 +9142 +9143 +9144 +9145 +9146 +9147 +9148 +9149 +915 +9150 +9151 +9152 +9153 +9154 +9155 +9156 +9157 +9158 +9159 +916 +9160 +9161 +9162 +9163 +9164 +9165 +9166 +9167 +9168 +9169 +917 +9170 +9171 +9172 +9173 +9174 +9175 +9176 +9177 +9178 +9179 +918 +9180 +9181 +9182 +9183 +9184 +9185 +9186 +9187 +9188 +9189 +919 +9190 +9191 +9192 +9193 +9194 +9195 +9196 +9197 +9198 +9199 +92 +920 +9200 +9201 +9202 +9203 +9204 +9205 +9206 +9207 +9208 +9209 +921 +9210 +9211 +9212 +9213 +9214 +9215 +9216 +9217 +9218 +9219 +922 +9220 +9221 +9222 +9223 +9224 +9225 +9226 +9227 +9228 +9229 +923 +9230 +9231 +9232 +9233 +9234 +9235 +9236 +9237 +9238 +9239 +924 +9240 +9241 +9242 +9243 +9244 +9245 +9246 +9247 +9248 +9249 +925 +9250 +9251 +9252 +9253 +9254 +9255 +9256 +9257 +9258 +9259 +926 +9260 +9261 +9262 +9263 +9264 +9265 +9266 +9267 +9268 +9269 +927 +9270 +9271 +9272 +9273 +9274 +9275 +9276 +9277 +9278 +9279 +928 +9280 +9281 +9282 +9283 +9284 +9285 +9286 +9287 +9288 +9289 +929 +9290 +9291 +9292 +9293 +9294 +9295 +9296 +9297 +9298 +9299 +93 +930 +9300 +9301 +9302 +9303 +9304 +9305 +9306 +9307 +9308 +9309 +931 +9310 +9311 +9312 +9313 +9314 +9315 +9316 +9317 +9318 +9319 +932 +9320 +9321 +9322 +9323 +9324 +9325 +9326 +9327 +9328 +9329 +933 +9330 +9331 +9332 +9333 +9334 +9335 +9336 +9337 +9338 +9339 +934 +9340 +9341 +9342 +9343 +9344 +9345 +9346 +9347 +9348 +9349 +935 +9350 +9351 +9352 +9353 +9354 +9355 +9356 +9357 +9358 +9359 +936 +9360 +9361 +9362 +9363 +9364 +9365 +9366 +9367 +9368 +9369 +937 +9370 +9371 +9372 +9373 +9374 +9375 +9376 +9377 +9378 +9379 +938 +9380 +9381 +9382 +9383 +9384 +9385 +9386 +9387 +9388 +9389 +939 +9390 +9391 +9392 +9393 +9394 +9395 +9396 +9397 +9398 +9399 +94 +940 +9400 +9401 +9402 +9403 +9404 +9405 +9406 +9407 +9408 +9409 +941 +9410 +9411 +9412 +9413 +9414 +9415 +9416 +9417 +9418 +9419 +942 +9420 +9421 +9422 +9423 +9424 +9425 +9426 +9427 +9428 +9429 +943 +9430 +9431 +9432 +9433 +9434 +9435 +9436 +9437 +9438 +9439 +944 +9440 +9441 +9442 +9443 +9444 +9445 +9446 +9447 +9448 +9449 +945 +9450 +9451 +9452 +9453 +9454 +9455 +9456 +9457 +9458 +9459 +946 +9460 +9461 +9462 +9463 +9464 +9465 +9466 +9467 +9468 +9469 +947 +9470 +9471 +9472 +9473 +9474 +9475 +9476 +9477 +9478 +9479 +948 +9480 +9481 +9482 +9483 +9484 +9485 +9486 +9487 +9488 +9489 +949 +9490 +9491 +9492 +9493 +9494 +9495 +9496 +9497 +9498 +9499 +95 +950 +9500 +9501 +9502 +9503 +9504 +9505 +9506 +9507 +9508 +9509 +951 +9510 +9511 +9512 +9513 +9514 +9515 +9516 +9517 +9518 +9519 +952 +9520 +9521 +9522 +9523 +9524 +9525 +9526 +9527 +9528 +9529 +953 +9530 +9531 +9532 +9533 +9534 +9535 +9536 +9537 +9538 +9539 +954 +9540 +9541 +9542 +9543 +9544 +9545 +9546 +9547 +9548 +9549 +955 +9550 +9551 +9552 +9553 +9554 +9555 +9556 +9557 +9558 +9559 +956 +9560 +9561 +9562 +9563 +9564 +9565 +9566 +9567 +9568 +9569 +957 +9570 +9571 +9572 +9573 +9574 +9575 +9576 +9577 +9578 +9579 +958 +9580 +9581 +9582 +9583 +9584 +9585 +9586 +9587 +9588 +9589 +959 +9590 +9591 +9592 +9593 +9594 +9595 +9596 +9597 +9598 +9599 +96 +960 +9600 +9601 +9602 +9603 +9604 +9605 +9606 +9607 +9608 +9609 +961 +9610 +9611 +9612 +9613 +9614 +9615 +9616 +9617 +9618 +9619 +962 +9620 +9621 +9622 +9623 +9624 +9625 +9626 +9627 +9628 +9629 +963 +9630 +9631 +9632 +9633 +9634 +9635 +9636 +9637 +9638 +9639 +964 +9640 +9641 +9642 +9643 +9644 +9645 +9646 +9647 +9648 +9649 +965 +9650 +9651 +9652 +9653 +9654 +9655 +9656 +9657 +9658 +9659 +966 +9660 +9661 +9662 +9663 +9664 +9665 +9666 +9667 +9668 +9669 +967 +9670 +9671 +9672 +9673 +9674 +9675 +9676 +9677 +9678 +9679 +968 +9680 +9681 +9682 +9683 +9684 +9685 +9686 +9687 +9688 +9689 +969 +9690 +9691 +9692 +9693 +9694 +9695 +9696 +9697 +9698 +9699 +97 +970 +9700 +9701 +9702 +9703 +9704 +9705 +9706 +9707 +9708 +9709 +971 +9710 +9711 +9712 +9713 +9714 +9715 +9716 +9717 +9718 +9719 +972 +9720 +9721 +9722 +9723 +9724 +9725 +9726 +9727 +9728 +9729 +973 +9730 +9731 +9732 +9733 +9734 +9735 +9736 +9737 +9738 +9739 +974 +9740 +9741 +9742 +9743 +9744 +9745 +9746 +9747 +9748 +9749 +975 +9750 +9751 +9752 +9753 +9754 +9755 +9756 +9757 +9758 +9759 +976 +9760 +9761 +9762 +9763 +9764 +9765 +9766 +9767 +9768 +9769 +977 +9770 +9771 +9772 +9773 +9774 +9775 +9776 +9777 +9778 +9779 +978 +9780 +9781 +9782 +9783 +9784 +9785 +9786 +9787 +9788 +9789 +979 +9790 +9791 +9792 +9793 +9794 +9795 +9796 +9797 +9798 +9799 +98 +980 +9800 +9801 +9802 +9803 +9804 +9805 +9806 +9807 +9808 +9809 +981 +9810 +9811 +9812 +9813 +9814 +9815 +9816 +9817 +9818 +9819 +982 +9820 +9821 +9822 +9823 +9824 +9825 +9826 +9827 +9828 +9829 +983 +9830 +9831 +9832 +9833 +9834 +9835 +9836 +9837 +9838 +9839 +984 +9840 +9841 +9842 +9843 +9844 +9845 +9846 +9847 +9848 +9849 +985 +9850 +9851 +9852 +9853 +9854 +9855 +9856 +9857 +9858 +9859 +986 +9860 +9861 +9862 +9863 +9864 +9865 +9866 +9867 +9868 +9869 +987 +9870 +9871 +9872 +9873 +9874 +9875 +9876 +9877 +9878 +9879 +988 +9880 +9881 +9882 +9883 +9884 +9885 +9886 +9887 +9888 +9889 +989 +9890 +9891 +9892 +9893 +9894 +9895 +9896 +9897 +9898 +9899 +99 +990 +9900 +9901 +9902 +9903 +9904 +9905 +9906 +9907 +9908 +9909 +991 +9910 +9911 +9912 +9913 +9914 +9915 +9916 +9917 +9918 +9919 +992 +9920 +9921 +9922 +9923 +9924 +9925 +9926 +9927 +9928 +9929 +993 +9930 +9931 +9932 +9933 +9934 +9935 +9936 +9937 +9938 +9939 +994 +9940 +9941 +9942 +9943 +9944 +9945 +9946 +9947 +9948 +9949 +995 +9950 +9951 +9952 +9953 +9954 +9955 +9956 +9957 +9958 +9959 +996 +9960 +9961 +9962 +9963 +9964 +9965 +9966 +9967 +9968 +9969 +997 +9970 +9971 +9972 +9973 +9974 +9975 +9976 +9977 +9978 +9979 +998 +9980 +9981 +9982 +9983 +9984 +9985 +9986 +9987 +9988 +9989 +999 +9990 +9991 +9992 +9993 +9994 +9995 +9996 +9997 +9998 +9999 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 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 + + +-- !query 51 +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 51 schema +struct +-- !query 51 output +1 1.5 +2 2.0 +3 NULL +4 NULL + + +-- !query 52 +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 52 schema +struct +-- !query 52 output +1 1.5 +2 2.0 +3 NULL +4 NULL + + +-- !query 53 +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 53 schema +struct +-- !query 53 output +1 1.5 +2 2.0 +3 NULL +4 NULL + + +-- !query 54 +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) +-- !query 54 schema +struct +-- !query 54 output +1 2 +2 2.5 +3 NULL +4 NULL + + +-- !query 55 +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- !query 55 schema +struct +-- !query 55 output +1 NULL +2 NULL +3 NULL +4 NULL + + +-- !query 56 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 56 schema +struct +-- !query 56 output +1 3 +2 2 +3 NULL +4 NULL + + +-- !query 57 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 57 schema +struct +-- !query 57 output +1 3 +2 2 +3 NULL +4 NULL + + +-- !query 58 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 58 schema +struct +-- !query 58 output +1 3 +2 2 +3 NULL +4 NULL + + +-- !query 59 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) +-- !query 59 schema +struct +-- !query 59 output +1 3.3000000000000003 +2 2.2 +3 NULL +4 NULL + + +-- !query 60 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- !query 60 schema +struct +-- !query 60 output +1 NULL +2 NULL +3 NULL +4 NULL + + +-- !query 61 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) +-- !query 61 schema +struct +-- !query 61 output +1 3.3 +2 2.2 +3 NULL +4 NULL + + +-- !query 62 +SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) +-- !query 62 schema +struct +-- !query 62 output +3 +5 +6.01 + + +-- !query 63 +SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 63 schema +struct +-- !query 63 output +1 2 +2 1 +3 0 +4 0 + + +-- !query 64 +SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 64 schema +struct +-- !query 64 output +1 4 +2 3 +3 2 +4 1 + + +-- !query 65 +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 65 schema +struct +-- !query 65 output +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 + + +-- !query 66 +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 66 schema +struct +-- !query 66 output +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 + + +-- !query 67 +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 67 schema +struct +-- !query 67 output +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 + + +-- !query 68 +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 68 schema +struct +-- !query 68 output +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 + + +-- !query 69 +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 69 schema +struct +-- !query 69 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 70 +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 70 schema +struct +-- !query 70 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 71 +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 71 schema +struct +-- !query 71 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 72 +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 72 schema +struct +-- !query 72 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 73 +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 73 schema +struct +-- !query 73 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 74 +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 74 schema +struct +-- !query 74 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 75 +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 75 schema +struct +-- !query 75 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 76 +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 76 schema +struct +-- !query 76 output +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN + + +-- !query 77 +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 77 schema +struct +-- !query 77 output +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 + + +-- !query 78 +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 78 schema +struct +-- !query 78 output +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 + + +-- !query 79 +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 79 schema +struct +-- !query 79 output +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 + + +-- !query 80 +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 80 schema +struct +-- !query 80 output +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 + + +-- !query 81 +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 81 schema +struct +-- !query 81 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 82 +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 82 schema +struct +-- !query 82 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 83 +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 83 schema +struct +-- !query 83 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 84 +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- !query 84 schema +struct +-- !query 84 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 85 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 85 schema +struct +-- !query 85 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 86 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 86 schema +struct +-- !query 86 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 87 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 87 schema +struct +-- !query 87 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 88 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 88 schema +struct +-- !query 88 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 89 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 89 schema +struct +-- !query 89 output +1 1 +2 2 +3 NULL +4 NULL + + +-- !query 90 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- !query 90 schema +struct +-- !query 90 output +1 3 +2 2 +3 NULL +4 NULL + + +-- !query 91 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) +-- !query 91 schema +struct +-- !query 91 output +1 3 +2 6 +3 9 +4 7 From 7c19413e047a51e81ead2f78bff7ea5a1a6fe3f7 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sun, 16 Jun 2019 11:07:59 -0300 Subject: [PATCH 02/25] Adds new references to SQL jiras Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 108 +++---- .../sql-tests/results/pgSQL/window.sql.out | 275 +++++++++--------- .../apache/spark/sql/SQLQueryTestSuite.scala | 26 ++ 3 files changed, 213 insertions(+), 196 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index a0891d6fc8bee..4a4a914b9d078 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -32,8 +32,8 @@ GROUP BY four, ten ORDER BY four, ten; SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname); --- I get an error when trying `order by rank() over w`, however it works for `order by r' if column rank is renamed to r -SELECT depname, empno, salary, rank() OVER w as r FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY r; +-- [SPARK-28064] Order by does not accept a call to rank() +-- SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w; SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10; @@ -55,13 +55,13 @@ SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 W SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10; --- Spark does not accept null as input for `ntile` +-- [SPARK-28065] ntile does not accept NULL as input -- SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; -- Spark fills with NULL instead of white space SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; --- `lag` second argument must be a literal? +-- `lag` second argument must be a literal in Spark -- SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -- SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; @@ -89,15 +89,10 @@ FROM tenk1 GROUP BY ten, two; SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10; --- Original PSQL query: --- SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + --- sum(hundred) OVER (PARTITION BY four ORDER BY ten))::varchar AS cntsum --- FROM tenk1 WHERE unique2 < 10; SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + sum(hundred) OVER (PARTITION BY four ORDER BY ten)) AS cntsum FROM tenk1 WHERE unique2 < 10; --- opexpr with different windows evaluation. SELECT * FROM( SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, @@ -111,13 +106,11 @@ SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHE SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER win AS wsum FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten); --- more than one window with GROUP BY SELECT sum(salary), row_number() OVER (ORDER BY depname), sum(sum(salary)) OVER (ORDER BY depname DESC) FROM empsalary GROUP BY depname; --- identical windows with different names SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); @@ -125,10 +118,8 @@ FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); -- SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) -- FROM tenk1 s WHERE unique2 < 10; --- empty table SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s; --- mixture of agg/wfunc in the same window SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC); -- strict aggs @@ -147,23 +138,21 @@ create temporary view int4_tbl as select * from values (2147483647), (-2147483647) as int4_tbl(f1); --- window function over ungrouped agg over empty row set + SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42; --- window function with ORDER BY an expression involving aggregates (9.1 bug) select ten, sum(unique1) + sum(unique2) as res, rank() over (order by sum(unique1) + sum(unique2)) as rank from tenk1 group by ten order by ten; --- no costs_off? +-- explain costs off unavailable at Spark -- explain (costs off) -- select first_value(max(x)) over (), y -- from (select unique1 as x, ten+four as y from tenk1) ss -- group by y; --- test non-default frame specifications SELECT four, ten, sum(ten) over (partition by four order by ten), last_value(ten) over (partition by four order by ten) @@ -205,14 +194,15 @@ FROM tenk1 WHERE unique1 < 10; -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; + -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; @@ -223,15 +213,15 @@ FROM tenk1 WHERE unique1 < 10; -- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; @@ -252,14 +242,14 @@ FROM tenk1 WHERE unique1 < 10; -- unique1, four -- FROM tenk1 WHERE unique1 < 10; -- --- -- broken --- -- SELECT sum(unique1) over (w range between current row and unbounded following), --- -- unique1, four --- -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- -- --- -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), --- -- unique1, four --- -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +-- broken +-- SELECT sum(unique1) over (w range between current row and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +-- +-- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); -- -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), -- unique1, four @@ -275,15 +265,12 @@ FROM tenk1 WHERE unique1 < 10; -- FROM tenk1 WHERE unique1 < 10 -- WINDOW w AS (order by four range between current row and unbounded following); --- broken -- SELECT sum(unique1) over -- (order by unique1 -- rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), -- unique1 -- FROM tenk1 WHERE unique1 < 10; - --- we don't have a generate_series? -- CREATE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following) as sum_rows -- FROM generate_series(1, 10) i; @@ -510,83 +497,83 @@ FROM tenk1 WHERE unique1 < 10; -- SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between current row and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude current row), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude group), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude ties), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following),unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- + -- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- + -- select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- + -- select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- + -- select first_value(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude current row), -- lead(salary) over(order by enroll_date groups between 1 following and 3 following exclude ties), -- nth_value(salary, 1) over(order by enroll_date groups between 1 following and 3 following -- exclude ties), -- salary, enroll_date from empsalary; --- + -- select last_value(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude group), -- lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), @@ -639,9 +626,8 @@ FROM tenk1 WHERE unique1 < 10; -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); -- with UNION/we didn't have tenk2 yet --- SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; --- check some degenerate cases create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); @@ -750,7 +736,7 @@ SELECT count() OVER () FROM tenk1; -- min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary -- FROM empsalary) emp -- WHERE depname = 'sales'; --- + -- -- Test Sort node reordering -- EXPLAIN (COSTS OFF) -- SELECT @@ -762,8 +748,6 @@ SELECT count() OVER () FROM tenk1; -- restarts the aggregation from scratch. The second aggregate is supposed -- to test cases where only some aggregates restart, the third one checks -- that one aggregate restarting doesn't cause others to restart. - - -- WITH -- vs AS ( -- SELECT i, (random() * 100)::int4 AS v @@ -784,10 +768,6 @@ SELECT count() OVER () FROM tenk1; -- ORDER BY vs.i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING -- ); - --- Test various built-in aggregates that have moving-aggregate support - --- test inverse transition functions handle NULLs properly SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); @@ -912,7 +892,11 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v); --- bool_and? +-- [SPARK-27880] Implement boolean aggregates(BOOL_AND, BOOL_OR and EVERY) -- SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w -- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) -- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); + +-- cleanup +drop table empsalary; +drop table t1; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 1c913896f8ff3..eee49b0708d96 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 92 +-- Number of queries: 94 -- !query 0 @@ -113,27 +113,10 @@ sales 4 4800 14600 -- !query 6 -SELECT depname, empno, salary, rank() OVER w as r FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY r --- !query 6 schema -struct --- !query 6 output -develop 7 4200 1 -sales 4 4800 1 -sales 3 4800 1 -personnel 5 3500 1 -develop 9 4500 2 -personnel 2 3900 2 -develop 10 5200 3 -develop 11 5200 3 -sales 1 5000 3 -develop 8 6000 5 - - --- !query 7 SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10 --- !query 7 schema +-- !query 6 schema struct --- !query 7 output +-- !query 6 output 10 10 10 @@ -146,11 +129,11 @@ struct --- !query 8 output +-- !query 7 output 10 10 10 @@ -163,19 +146,19 @@ struct --- !query 9 output +-- !query 8 output --- !query 10 +-- !query 9 SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10 --- !query 10 schema +-- !query 9 schema struct --- !query 10 output +-- !query 9 output 0 0 0 0 0 0 0 4 0 @@ -188,11 +171,11 @@ struct 5 1 1 --- !query 11 +-- !query 10 SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10 --- !query 11 schema +-- !query 10 schema struct --- !query 11 output +-- !query 10 output 1 10 2 @@ -205,11 +188,11 @@ struct --- !query 12 output +-- !query 11 output 1 0 0 1 0 0 1 0 2 @@ -222,11 +205,11 @@ struct 4 9 1 --- !query 13 +-- !query 12 SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 13 schema +-- !query 12 schema struct --- !query 13 output +-- !query 12 output 1 0 0 1 0 0 1 0 2 @@ -239,11 +222,11 @@ struct --- !query 14 output +-- !query 13 output 0.0 0 0 0.0 0 0 0.0 0 2 @@ -256,11 +239,11 @@ struct --- !query 15 output +-- !query 14 output 0.5 1 1 0.5 1 1 0.5 1 3 @@ -273,11 +256,11 @@ struct --- !query 16 output +-- !query 15 output 1 0 0 1 0 0 1 0 2 @@ -290,11 +273,11 @@ struct --- !query 17 output +-- !query 16 output 0 0 0 0 4 0 1 1 1 @@ -307,11 +290,11 @@ NULL 1 1 NULL 1 3 --- !query 18 +-- !query 17 SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 18 schema +-- !query 17 schema struct --- !query 18 output +-- !query 17 output 0 0 0 1 1 1 3 1 3 @@ -324,11 +307,11 @@ NULL 4 0 NULL 9 1 --- !query 19 +-- !query 18 SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 19 schema +-- !query 18 schema struct --- !query 19 output +-- !query 18 output 0 0 0 14 1 1 18 7 1 @@ -341,11 +324,11 @@ NULL 4 0 NULL 9 1 --- !query 20 +-- !query 19 SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 20 schema +-- !query 19 schema struct --- !query 20 output +-- !query 19 output -1 0 2 -1 3 3 -1 4 0 @@ -358,11 +341,11 @@ struct --- !query 21 output +-- !query 20 output 0 0 0 0 0 0 0 0 2 @@ -375,11 +358,11 @@ struct --- !query 22 output +-- !query 21 output 0 4 0 1 1 1 1 1 1 @@ -392,13 +375,13 @@ struct --- !query 23 output +-- !query 22 output 4 0 0 4 0 0 4 4 0 @@ -411,12 +394,12 @@ struct --- !query 24 output +-- !query 23 output 0 0 45000 45000 1 1 46000 46000 2 0 47000 92000 @@ -429,11 +412,11 @@ struct 9 1 54000 250000 --- !query 25 +-- !query 24 SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10 --- !query 25 schema +-- !query 24 schema struct --- !query 25 output +-- !query 24 output 2 3 2 3 4 1 @@ -442,13 +425,13 @@ struct --- !query 26 output +-- !query 25 output 136 22 22 @@ -461,7 +444,7 @@ struct 92 --- !query 27 +-- !query 26 SELECT * FROM( SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, @@ -469,17 +452,17 @@ SELECT * FROM( sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS twosum FROM tenk1 )sub WHERE total <> fourcount + twosum --- !query 27 schema +-- !query 26 schema struct --- !query 27 output +-- !query 26 output --- !query 28 +-- !query 27 SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10 --- !query 28 schema +-- !query 27 schema struct --- !query 28 output +-- !query 27 output 0.0 0.0 0.0 @@ -492,12 +475,12 @@ struct --- !query 29 output +-- !query 28 output 0 0 45000 45000 1 1 46000 46000 2 0 47000 92000 @@ -510,25 +493,25 @@ struct 9 1 54000 250000 --- !query 30 +-- !query 29 SELECT sum(salary), row_number() OVER (ORDER BY depname), sum(sum(salary)) OVER (ORDER BY depname DESC) FROM empsalary GROUP BY depname --- !query 30 schema +-- !query 29 schema struct --- !query 30 output +-- !query 29 output 14600 3 14600 25100 1 47100 7400 2 22000 --- !query 31 +-- !query 30 SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary) --- !query 31 schema +-- !query 30 schema struct --- !query 31 output +-- !query 30 output 11600 3 16100 4 25700 6 @@ -541,19 +524,19 @@ struct --- !query 32 output +-- !query 31 output --- !query 33 +-- !query 32 SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) --- !query 33 schema +-- !query 32 schema struct --- !query 33 output +-- !query 32 output 14600 2 14600 2 16400 2 @@ -566,7 +549,7 @@ struct --- !query 34 output +-- !query 33 output 1 sales 5000 1000 200 1000 200 10 develop 5200 500 200 500 200 11 develop 5200 500 200 500 200 @@ -589,7 +572,7 @@ struct --- !query 35 output +-- !query 34 output --- !query 36 +-- !query 35 SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 --- !query 36 schema +-- !query 35 schema struct --- !query 36 output +-- !query 35 output 0 --- !query 37 +-- !query 36 select ten, sum(unique1) + sum(unique2) as res, rank() over (order by sum(unique1) + sum(unique2)) as rank from tenk1 group by ten order by ten --- !query 37 schema +-- !query 36 schema struct --- !query 37 output +-- !query 36 output 0 9976146 4 1 10114187 9 2 10059554 8 @@ -632,14 +615,14 @@ struct 9 10040184 7 --- !query 38 +-- !query 37 SELECT four, ten, sum(ten) over (partition by four order by ten), last_value(ten) over (partition by four order by ten) FROM (select distinct ten, four from tenk1) ss --- !query 38 schema +-- !query 37 schema struct --- !query 38 output +-- !query 37 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -662,14 +645,14 @@ struct --- !query 39 output +-- !query 38 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -692,14 +675,14 @@ struct --- !query 40 output +-- !query 39 output 0 0 20 8 0 2 20 8 0 4 20 8 @@ -722,14 +705,14 @@ struct --- !query 41 output +-- !query 40 output 0 0.0 0.0 0.0 0 0.5 0.5 0.5 0 1.0 1.5 1.0 @@ -752,14 +735,14 @@ struct --- !query 42 output +-- !query 41 output 0 0.0 0.0 0.0 0 0.5 0.5 0.5 0 1.0 1.5 1.0 @@ -782,13 +765,13 @@ struct --- !query 43 output +-- !query 42 output 10 3 3 10 7 3 18 2 2 @@ -801,13 +784,13 @@ struct --- !query 44 output +-- !query 43 output 0 0 0 10 3 3 15 5 1 @@ -820,13 +803,13 @@ struct --- !query 45 output +-- !query 44 output 10 0 0 13 2 2 15 7 3 @@ -839,6 +822,14 @@ struct +-- !query 45 output + + + -- !query 46 create table t1 (f1 int, f2 int) using parquet -- !query 46 schema @@ -21405,3 +21396,19 @@ struct +-- !query 92 output + + + +-- !query 93 +drop table t1 +-- !query 93 schema +struct<> +-- !query 93 output + diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala index 4bdf25051127c..bb3088ac262ea 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala @@ -529,6 +529,32 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext { """.stripMargin) .load(testFile("test-data/postgresql/tenk.data")) .createOrReplaceTempView("tenk1") + + session + .read + .format("csv") + .options(Map("delimiter" -> "\t", "header" -> "false")) + .schema( + """ + |unique1 int, + |unique2 int, + |two int, + |four int, + |ten int, + |twenty int, + |hundred int, + |thousand int, + |twothousand int, + |fivethous int, + |tenthous int, + |odd int, + |even int, + |stringu1 string, + |stringu2 string, + |string4 string + """.stripMargin) + .load(testFile("test-data/postgresql/tenk.data")) + .createOrReplaceTempView("tenk2") } private val originalTimeZone = TimeZone.getDefault From 1f53dc9cd769e2cc0c6ac8d21d08107ec7575bcb Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sun, 16 Jun 2019 16:16:11 -0300 Subject: [PATCH 03/25] remove unprecise comment Signed-off-by: DylanGuedes --- .../src/test/resources/sql-tests/inputs/pgSQL/window.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 4a4a914b9d078..463efe96824da 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -625,7 +625,7 @@ FROM tenk1 WHERE unique1 < 10; -- FROM cte -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); --- with UNION/we didn't have tenk2 yet +-- with UNION SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; create table t1 (f1 int, f2 int) using parquet; @@ -666,7 +666,6 @@ insert into t1 values (1,1),(1,2),(2,2); -- groups between 1 following and 2 following) -- from t1 where f1 = f2; --- ordering by a non-integer constant is allowed SELECT rank() OVER (ORDER BY length('abc')); -- can't order by another window function @@ -737,7 +736,7 @@ SELECT count() OVER () FROM tenk1; -- FROM empsalary) emp -- WHERE depname = 'sales'; --- -- Test Sort node reordering +-- Test Sort node reordering -- EXPLAIN (COSTS OFF) -- SELECT -- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), From 4f08ee934a4defe57c7c3ff509401ddb81fa33fa Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sun, 16 Jun 2019 18:58:33 -0300 Subject: [PATCH 04/25] adds new reference to jira Signed-off-by: DylanGuedes --- sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 463efe96824da..aa29ddf5627c2 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -61,7 +61,7 @@ SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < -- Spark fills with NULL instead of white space SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; --- `lag` second argument must be a literal in Spark +-- [SPARK-28068] `lag` second argument must be a literal in Spark -- SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -- SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; @@ -626,7 +626,7 @@ FROM tenk1 WHERE unique1 < 10; -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); -- with UNION -SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; +-- SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); From f2895ffe7c5c492f4674ad0d9ed9df8ad63c6f9b Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 17 Jun 2019 17:16:00 -0300 Subject: [PATCH 05/25] Adds new comments about queries. Update others SQL golden files Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 537 +++++++++--------- .../sql-tests/results/pgSQL/window.sql.out | 415 ++++++++------ .../sql-tests/results/show-tables.sql.out | 2 + 3 files changed, 494 insertions(+), 460 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index aa29ddf5627c2..30456cd7922fa 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -4,6 +4,9 @@ -- Window Functions Testing -- https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/window.sql +-- The queries that are not (fully) available at Spark, I added an [ERROR] tag, so if you +-- are looking for queries to fix, you can just look for ERROR. + CREATE TABLE empsalary ( depname string, empno integer, @@ -33,7 +36,7 @@ GROUP BY four, ten ORDER BY four, ten; SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname); -- [SPARK-28064] Order by does not accept a call to rank() --- SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w; +-- [ERROR] SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w; SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10; @@ -56,14 +59,14 @@ SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 W SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10; -- [SPARK-28065] ntile does not accept NULL as input --- SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; +-- [ERROR] SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; -- Spark fills with NULL instead of white space SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -- [SPARK-28068] `lag` second argument must be a literal in Spark --- SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; --- SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +-- [ERROR] SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +-- [ERROR] SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; @@ -73,15 +76,14 @@ SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FRO SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; --- last_value returns the last row of the frame, which is CURRENT ROW in ORDER BY window. SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; SELECT last_value(ten) OVER (PARTITION BY four), ten, four FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s ORDER BY four, ten; --- nth_value does not exist? --- SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four -- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s; SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER (PARTITION BY two ORDER BY ten) AS wsum @@ -114,15 +116,14 @@ FROM empsalary GROUP BY depname; SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); --- subplan/broken --- SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) +-- +-- [ERROR] SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) -- FROM tenk1 s WHERE unique2 < 10; SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s; SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC); --- strict aggs SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( SELECT *, CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus, @@ -147,11 +148,9 @@ select ten, from tenk1 group by ten order by ten; --- explain costs off unavailable at Spark --- explain (costs off) --- select first_value(max(x)) over (), y --- from (select unique1 as x, ten+four as y from tenk1) ss --- group by y; +select first_value(max(x)) over (), y + from (select unique1 as x, ten+four as y from tenk1) ss + group by y; SELECT four, ten, sum(ten) over (partition by four order by ten), @@ -190,418 +189,410 @@ SELECT sum(unique1) over (rows between 2 preceding and 2 following), unique1, four FROM tenk1 WHERE unique1 < 10; --- broken --- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), +-- Error in the following queries. +-- Related with `exclude` or the `following` +-- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), +-- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), +-- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), +-- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; -- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), +-- [ERROR] SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), +-- [ERROR] SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), +-- [ERROR] SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), +-- [ERROR] SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), + +-- [ERROR] SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), + +-- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (rows between 1 following and 3 following), + +-- [ERROR] SELECT sum(unique1) over (rows between 1 following and 3 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (rows between unbounded preceding and 1 following), + +-- [ERROR] SELECT sum(unique1) over (rows between unbounded preceding and 1 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- broken --- SELECT sum(unique1) over (w range between current row and unbounded following), + +-- Spark does not accept the window definition too far? +-- [ERROR] SELECT sum(unique1) over (w range between current row and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- --- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), + +-- [ERROR] SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- --- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), + +-- [ERROR] SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- --- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), + +-- [ERROR] SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); -- --- SELECT first_value(unique1) over w, +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] SELECT first_value(unique1) over w, -- nth_value(unique1, 2) over w AS nth_2, -- last_value(unique1) over w, unique1, four -- FROM tenk1 WHERE unique1 < 10 -- WINDOW w AS (order by four range between current row and unbounded following); --- SELECT sum(unique1) over +-- [ERROR] SELECT sum(unique1) over -- (order by unique1 -- rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), -- unique1 -- FROM tenk1 WHERE unique1 < 10; --- CREATE TEMP VIEW v_window AS +-- [ERROR] CREATE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following) as sum_rows --- FROM generate_series(1, 10) i; --- --- SELECT * FROM v_window; --- --- SELECT pg_get_viewdef('v_window'); --- --- CREATE OR REPLACE TEMP VIEW v_window AS +-- FROM range(1, 10) i; + +-- [ERROR] SELECT * FROM v_window; + +-- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following --- exclude current row) as sum_rows FROM generate_series(1, 10) i; --- --- SELECT * FROM v_window; --- --- SELECT pg_get_viewdef('v_window'); --- --- CREATE OR REPLACE TEMP VIEW v_window AS +-- exclude current row) as sum_rows FROM range(1, 10) i; + +-- [ERROR] SELECT * FROM v_window; + +-- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following --- exclude group) as sum_rows FROM generate_series(1, 10) i; --- --- SELECT * FROM v_window; --- --- SELECT pg_get_viewdef('v_window'); --- --- CREATE OR REPLACE TEMP VIEW v_window AS +-- exclude group) as sum_rows FROM range(1, 10) i; + +-- [ERROR] SELECT * FROM v_window; + +-- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude ties) as sum_rows FROM generate_series(1, 10) i; --- --- SELECT * FROM v_window; --- --- SELECT pg_get_viewdef('v_window'); --- --- CREATE OR REPLACE TEMP VIEW v_window AS + +-- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude no others) as sum_rows FROM generate_series(1, 10) i; --- --- SELECT * FROM v_window; --- --- SELECT pg_get_viewdef('v_window'); --- --- CREATE OR REPLACE TEMP VIEW v_window AS + +-- [ERROR] SELECT * FROM v_window; + +-- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM generate_series(1, 10) i; --- --- SELECT * FROM v_window; --- --- SELECT pg_get_viewdef('v_window'); --- --- DROP VIEW v_window; --- --- CREATE TEMP VIEW v_window AS + +-- [ERROR] SELECT * FROM v_window; + +-- [ERROR] SELECT pg_get_viewdef('v_window'); + +-- [ERROR] DROP VIEW v_window; + +-- [ERROR] CREATE TEMP VIEW v_window AS -- SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i -- FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i; --- --- SELECT pg_get_viewdef('v_window'); --- --- -- RANGE offset PRECEDING/FOLLOWING tests --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding), + +-- RANGE offset PRECEDING/FOLLOWING tests +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding), + +-- [ERROR] SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others), + +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row), + +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group), + +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties), + +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties), + +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group), + +-- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following), + +-- [ERROR] SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; -- --- SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following +-- [ERROR] SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following -- exclude current row),unique1, four -- FROM tenk1 WHERE unique1 < 10; --- --- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following), + +-- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following), -- salary, enroll_date from empsalary; --- --- select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following), + +-- [ERROR] select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following), -- salary, enroll_date from empsalary; --- --- select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following), + +-- [ERROR] select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following), -- salary, enroll_date from empsalary; --- --- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + +-- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following -- exclude current row), salary, enroll_date from empsalary; --- --- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + +-- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following -- exclude group), salary, enroll_date from empsalary; --- --- select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + +-- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following -- exclude ties), salary, enroll_date from empsalary; --- --- select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), + +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), -- lead(salary) over(order by salary range between 1000 preceding and 1000 following), -- nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following), -- salary from empsalary; --- --- select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), + +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), -- lag(salary) over(order by salary range between 1000 preceding and 1000 following), -- salary from empsalary; --- --- select first_value(salary) over(order by salary range between 1000 following and 3000 following + +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] select first_value(salary) over(order by salary range between 1000 following and 3000 following -- exclude current row), -- lead(salary) over(order by salary range between 1000 following and 3000 following exclude ties), -- nth_value(salary, 1) over(order by salary range between 1000 following and 3000 following -- exclude ties), -- salary from empsalary; --- --- select last_value(salary) over(order by salary range between 1000 following and 3000 following + +-- [ERROR] select last_value(salary) over(order by salary range between 1000 following and 3000 following -- exclude group), -- lag(salary) over(order by salary range between 1000 following and 3000 following exclude group), -- salary from empsalary; --- --- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + +-- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude ties), -- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following), -- salary, enroll_date from empsalary; --- --- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + +-- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude ties), -- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude ties), -- salary, enroll_date from empsalary; --- --- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + +-- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude group), -- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude group), -- salary, enroll_date from empsalary; --- --- select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + +-- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude current row), -- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following -- exclude current row), -- salary, enroll_date from empsalary; --- --- -- RANGE offset PRECEDING/FOLLOWING with null values --- select x, y, + +-- in Spark, x is ambiguous for the following queries +-- [ERROR] select x, y, -- first_value(y) over w, -- last_value(y) over w -- from --- (select x, x as y from generate_series(1,5) as x +-- (select x, x as y from range(1,5) as x -- union all select null, 42 -- union all select null, 43) ss -- window w as -- (order by x asc nulls first range between 2 preceding and 2 following); --- --- select x, y, + +-- [ERROR] select x, y, -- first_value(y) over w, -- last_value(y) over w -- from --- (select x, x as y from generate_series(1,5) as x +-- (select x, x as y from range(1,5) as x -- union all select null, 42 -- union all select null, 43) ss -- window w as -- (order by x asc nulls last range between 2 preceding and 2 following); --- --- select x, y, + +-- [ERROR] select x, y, -- first_value(y) over w, -- last_value(y) over w -- from --- (select x, x as y from generate_series(1,5) as x +-- (select x, x as y from range(1,5) as x -- union all select null, 42 -- union all select null, 43) ss -- window w as -- (order by x desc nulls first range between 2 preceding and 2 following); --- --- select x, y, + +-- [ERROR] select x, y, -- first_value(y) over w, -- last_value(y) over w -- from --- (select x, x as y from generate_series(1,5) as x +-- (select x, x as y from range(1,5) as x -- union all select null, 42 -- union all select null, 43) ss -- window w as -- (order by x desc nulls last range between 2 preceding and 2 following); --- --- -- Check overflow behavior for various integer sizes --- --- select x, last_value(x) over (order by x::smallint range between current row and 2147450884 following) --- from generate_series(32764, 32766) x; --- --- select x, last_value(x) over (order by x::smallint desc range between current row and 2147450885 following) --- from generate_series(-32766, -32764) x; --- --- select x, last_value(x) over (order by x range between current row and 4 following) --- from generate_series(2147483644, 2147483646) x; --- --- select x, last_value(x) over (order by x desc range between current row and 5 following) --- from generate_series(-2147483646, -2147483644) x; --- --- select x, last_value(x) over (order by x range between current row and 4 following) --- from generate_series(9223372036854775804, 9223372036854775806) x; --- --- select x, last_value(x) over (order by x desc range between current row and 5 following) --- from generate_series(-9223372036854775806, -9223372036854775804) x; --- + +-- Check overflow behavior for various integer sizes +-- [ERROR] select x, last_value(x) over (order by x range between current row and 2147450884 following) +-- from range(32764, 32766) x; + +-- Spark does not define default column name as the name of the sub-query +-- instead, it calls the default column for `range()` as id +select x.id, last_value(x.id) over (order by x.id desc range between current row and 2147450885 following) +from range(-32766, -32764) x; + +select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +from range(2147483644, 2147483646) x; + +select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +from range(-2147483646, -2147483644) x; + +select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +from range(9223372036854775804, 9223372036854775806) x; + +select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +from range(-9223372036854775806, -9223372036854775804) x; -- GROUPS tests -- no `groups`? --- SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), +-- [ERROR] SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between current row and unbounded following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between current row and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), +-- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), +-- [ERROR] SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude current row), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude group), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude ties), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (partition by ten +-- [ERROR] SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following),unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (partition by ten +-- [ERROR] SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (partition by ten +-- [ERROR] SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- SELECT sum(unique1) over (partition by ten +-- [ERROR] SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- [ERROR] select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- select first_value(salary) over(order by enroll_date groups between 1 following and 3 following +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] select first_value(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude current row), -- lead(salary) over(order by enroll_date groups between 1 following and 3 following exclude ties), -- nth_value(salary, 1) over(order by enroll_date groups between 1 following and 3 following -- exclude ties), -- salary, enroll_date from empsalary; --- select last_value(salary) over(order by enroll_date groups between 1 following and 3 following +-- [ERROR] select last_value(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude group), -- lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), -- salary, enroll_date from empsalary; -- Show differences in offset interpretation between ROWS, RANGE, and GROUPS --- WITH cte (x) AS ( +-- [ERROR] WITH cte (x) AS ( -- SELECT * FROM generate_series(1, 35, 2) -- ) -- SELECT x, (sum(x) over w) -- FROM cte -- WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); --- --- WITH cte (x) AS ( + +-- [ERROR] WITH cte (x) AS ( -- SELECT * FROM generate_series(1, 35, 2) -- ) -- SELECT x, (sum(x) over w) -- FROM cte -- WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); --- WITH cte (x) AS ( +-- [ERROR] WITH cte (x) AS ( -- SELECT * FROM generate_series(1, 35, 2) -- ) -- SELECT x, (sum(x) over w) -- FROM cte -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); --- WITH cte (x) AS ( +-- [ERROR] WITH cte (x) AS ( -- select 1 union all select 1 union all select 1 union all -- SELECT * FROM generate_series(5, 49, 2) -- ) @@ -609,7 +600,7 @@ FROM tenk1 WHERE unique1 < 10; -- FROM cte -- WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); --- WITH cte (x) AS ( +-- [ERROR] WITH cte (x) AS ( -- select 1 union all select 1 union all select 1 union all -- SELECT * FROM generate_series(5, 49, 2) -- ) @@ -617,7 +608,7 @@ FROM tenk1 WHERE unique1 < 10; -- FROM cte -- WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); --- WITH cte (x) AS ( +-- [ERROR] WITH cte (x) AS ( -- select 1 union all select 1 union all select 1 union all -- SELECT * FROM generate_series(5, 49, 2) -- ) @@ -626,147 +617,125 @@ FROM tenk1 WHERE unique1 < 10; -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); -- with UNION --- SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; +-- [ERROR] SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); -- broken - costs and range are not available? --- select f1, sum(f1) over (partition by f1 +-- [ERROR] select f1, sum(f1) over (partition by f1 -- range between 1 preceding and 1 following) --- from t1 where f1 = f2; -- error, must have order by --- explain (costs off) +-- from t1 where f1 = f2; + +-- [ERROR] explain (costs off) -- select f1, sum(f1) over (partition by f1 order by f2 - -- range between 1 preceding and 1 following) +-- range between 1 preceding and 1 following) -- from t1 where f1 = f2; -- select f1, sum(f1) over (partition by f1 order by f2 -- range between 1 preceding and 1 following) -- from t1 where f1 = f2; --- select f1, sum(f1) over (partition by f1, f1 order by f2 --- range between 2 preceding and 1 preceding) + +-- [ERROR] select f1, sum(f1) over (partition by f1, f1 order by f2 +-- range between 2 preceding and 1 preceding) -- from t1 where f1 = f2; --- select f1, sum(f1) over (partition by f1, f2 order by f2 --- range between 1 following and 2 following) + +-- [ERROR] select f1, sum(f1) over (partition by f1, f2 order by f2 +-- range between 1 following and 2 following) -- from t1 where f1 = f2; --- select f1, sum(f1) over (partition by f1 --- groups between 1 preceding and 1 following) --- from t1 where f1 = f2; -- error, must have order by --- explain (costs off) --- select f1, sum(f1) over (partition by f1 order by f2 --- groups between 1 preceding and 1 following) +-- [ERROR] select f1, sum(f1) over (partition by f1 +-- groups between 1 preceding and 1 following) -- from t1 where f1 = f2; + +-- [ERROR] explain (costs off) -- select f1, sum(f1) over (partition by f1 order by f2 --- groups between 1 preceding and 1 following) +-- groups between 1 preceding and 1 following) -- from t1 where f1 = f2; --- select f1, sum(f1) over (partition by f1, f1 order by f2 --- groups between 2 preceding and 1 preceding) + +-- [ERROR] select f1, sum(f1) over (partition by f1 order by f2 +-- groups between 1 preceding and 1 following) +-- from t1 where f1 = f2; + +-- [ERROR] select f1, sum(f1) over (partition by f1, f1 order by f2 +-- groups between 2 preceding and 1 preceding) -- from t1 where f1 = f2; --- select f1, sum(f1) over (partition by f1, f2 order by f2 --- groups between 1 following and 2 following) + +-- [ERROR] select f1, sum(f1) over (partition by f1, f2 order by f2 +-- groups between 1 following and 2 following) -- from t1 where f1 = f2; SELECT rank() OVER (ORDER BY length('abc')); --- can't order by another window function --- random does not exist --- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); +-- [SPARK-28086] Adds `random()` to Spark +-- [ERROR] SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); -- some other errors --- broken --- SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; +-- [ERROR] SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; --- SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; +-- [ERROR] SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; --- broken --- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; +-- [ERROR] SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; --- broken --- SELECT * FROM rank() OVER (ORDER BY random()); +-- [SPARK-28086] Adds `random()` to Spark +-- [ERROR] SELECT * FROM rank() OVER (ORDER BY random()); SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); --- broken --- SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; +-- It does not work. Maybe it is related to not defining a window? +-- [ERROR] SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; SELECT count() OVER () FROM tenk1; --- SELECT generate_series(1, 100) OVER () FROM empsalary; + +-- Ok, first I migrated a call to `generate_series()`, given by Postgres, to +-- the equivalent Spark function, called `range()`. But `range()` seems less +-- flexible than `generate_series()` +-- [ERROR] SELECT range(1, 100) OVER () FROM empsalary; -- the error is weird --- SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; +-- [ERROR] SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; --- SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; +-- [SPARK-27764] Currently, Spark is missing nth_value +-- [ERROR] SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; --- filter -- FILTER does not work on spark? --- SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( +-- [ERROR] SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( -- sum(salary) FILTER (WHERE enroll_date > '2007-01-01') -- ) FILTER (WHERE depname <> 'sales') OVER (ORDER BY depname DESC) AS "filtered_sum", -- depname -- FROM empsalary GROUP BY depname; --- Test pushdown of quals into a subquery containing window functions - -- costs off didn't work? --- pushdown is safe because all PARTITION BY clauses include depname: --- EXPLAIN (COSTS OFF) +-- [ERROR] EXPLAIN (COSTS OFF) -- SELECT * FROM --- (SELECT depname, --- sum(salary) OVER (PARTITION BY depname) depsalary, --- min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary --- FROM empsalary) emp +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY depname) depsalary, +-- min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary +-- FROM empsalary) emp -- WHERE depname = 'sales'; --- pushdown is unsafe because there's a PARTITION BY clause without depname: --- EXPLAIN (COSTS OFF) +-- [ERROR] EXPLAIN (COSTS OFF) -- SELECT * FROM --- (SELECT depname, --- sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, --- min(salary) OVER (PARTITION BY depname) depminsalary --- FROM empsalary) emp +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, +-- min(salary) OVER (PARTITION BY depname) depminsalary +-- FROM empsalary) emp -- WHERE depname = 'sales'; --- Test Sort node collapsing --- EXPLAIN (COSTS OFF) +-- [ERROR] EXPLAIN (COSTS OFF) -- SELECT * FROM --- (SELECT depname, --- sum(salary) OVER (PARTITION BY depname order by empno) depsalary, --- min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary --- FROM empsalary) emp +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY depname order by empno) depsalary, +-- min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary +-- FROM empsalary) emp -- WHERE depname = 'sales'; --- Test Sort node reordering --- EXPLAIN (COSTS OFF) +-- [ERROR] EXPLAIN (COSTS OFF) -- SELECT --- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), --- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +-- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), +-- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) -- FROM empsalary; --- test that returning NULL from the inverse transition functions --- restarts the aggregation from scratch. The second aggregate is supposed --- to test cases where only some aggregates restart, the third one checks --- that one aggregate restarting doesn't cause others to restart. --- WITH --- vs AS ( --- SELECT i, (random() * 100)::int4 AS v --- FROM generate_series(1, 100) AS i --- ), --- sum_following AS ( --- SELECT i, SUM(v) OVER --- (ORDER BY i DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS s --- FROM vs --- ) --- SELECT DISTINCT --- sum_following.s = sum_int_randomrestart(v) OVER fwd AS eq1, --- -sum_following.s = sum_int_randomrestart(-v) OVER fwd AS eq2, --- 100*3+(vs.i-1)*3 = length(logging_agg_nonstrict(''::text) OVER fwd) AS eq3 --- FROM vs --- JOIN sum_following ON sum_following.i = vs.i --- WINDOW fwd AS ( --- ORDER BY vs.i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING --- ); - SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); @@ -881,7 +850,6 @@ SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWI SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); --- test that inverse transition functions work with various frame options SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); @@ -892,10 +860,11 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v); -- [SPARK-27880] Implement boolean aggregates(BOOL_AND, BOOL_OR and EVERY) --- SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w +-- [ERROR] SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w -- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) -- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); -- cleanup drop table empsalary; drop table t1; +drop view int4_tbl; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index eee49b0708d96..ab50f91d25e79 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 94 +-- Number of queries: 100 -- !query 0 @@ -616,13 +616,29 @@ struct -- !query 37 +select first_value(max(x)) over (), y + from (select unique1 as x, ten+four as y from tenk1) ss + group by y +-- !query 37 schema +struct +-- !query 37 output +9980 0 +9980 10 +9980 12 +9980 2 +9980 4 +9980 6 +9980 8 + + +-- !query 38 SELECT four, ten, sum(ten) over (partition by four order by ten), last_value(ten) over (partition by four order by ten) FROM (select distinct ten, four from tenk1) ss --- !query 37 schema +-- !query 38 schema struct --- !query 37 output +-- !query 38 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -645,14 +661,14 @@ struct --- !query 38 output +-- !query 39 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -675,14 +691,14 @@ struct --- !query 39 output +-- !query 40 output 0 0 20 8 0 2 20 8 0 4 20 8 @@ -705,14 +721,14 @@ struct --- !query 40 output +-- !query 41 output 0 0.0 0.0 0.0 0 0.5 0.5 0.5 0 1.0 1.5 1.0 @@ -735,14 +751,14 @@ struct --- !query 41 output +-- !query 42 output 0 0.0 0.0 0.0 0 0.5 0.5 0.5 0 1.0 1.5 1.0 @@ -765,13 +781,13 @@ struct --- !query 42 output +-- !query 43 output 10 3 3 10 7 3 18 2 2 @@ -784,13 +800,13 @@ struct --- !query 43 output +-- !query 44 output 0 0 0 10 3 3 15 5 1 @@ -803,13 +819,13 @@ struct --- !query 44 output +-- !query 45 output 10 0 0 13 2 2 15 7 3 @@ -822,46 +838,85 @@ struct --- !query 45 output - - - -- !query 46 -create table t1 (f1 int, f2 int) using parquet +select x.id, last_value(x.id) over (order by x.id desc range between current row and 2147450885 following) +from range(-32766, -32764) x -- !query 46 schema -struct<> +struct -- !query 46 output - +-32765 -32766 +-32766 -32766 -- !query 47 -insert into t1 values (1,1),(1,2),(2,2) +select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +from range(2147483644, 2147483646) x -- !query 47 schema -struct<> +struct -- !query 47 output - +2147483644 2147483645 +2147483645 2147483645 -- !query 48 --- range between 1 preceding and 1 following) +select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +from range(-2147483646, -2147483644) x +-- !query 48 schema +struct +-- !query 48 output +-2147483645 -2147483646 +-2147483646 -2147483646 + + +-- !query 49 +select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +from range(9223372036854775804, 9223372036854775806) x +-- !query 49 schema +struct +-- !query 49 output +9223372036854775804 NULL +9223372036854775805 NULL + + +-- !query 50 +select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +from range(-9223372036854775806, -9223372036854775804) x +-- !query 50 schema +struct +-- !query 50 output +-9223372036854775805 NULL +-9223372036854775806 NULL + + +-- !query 51 +create table t1 (f1 int, f2 int) using parquet +-- !query 51 schema +struct<> +-- !query 51 output + + + +-- !query 52 +insert into t1 values (1,1),(1,2),(2,2) +-- !query 52 schema +struct<> +-- !query 52 output + +-- !query 53 SELECT rank() OVER (ORDER BY length('abc')) --- !query 48 schema +-- !query 53 schema struct --- !query 48 output +-- !query 53 output 1 --- !query 49 +-- !query 54 SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1) --- !query 49 schema +-- !query 54 schema struct --- !query 49 output +-- !query 54 output 1 10 100 @@ -10864,11 +10919,11 @@ struct --- !query 50 output +-- !query 55 output 0 0 0 @@ -20871,179 +20926,179 @@ struct --- !query 51 output +-- !query 56 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 52 +-- !query 57 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 52 schema +-- !query 57 schema struct --- !query 52 output +-- !query 57 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 53 +-- !query 58 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 53 schema +-- !query 58 schema struct --- !query 53 output +-- !query 58 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 54 +-- !query 59 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 54 schema +-- !query 59 schema struct --- !query 54 output +-- !query 59 output 1 2 2 2.5 3 NULL 4 NULL --- !query 55 +-- !query 60 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 55 schema +-- !query 60 schema struct --- !query 55 output +-- !query 60 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 56 +-- !query 61 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 56 schema +-- !query 61 schema struct --- !query 56 output +-- !query 61 output 1 3 2 2 3 NULL 4 NULL --- !query 57 +-- !query 62 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 57 schema +-- !query 62 schema struct --- !query 57 output +-- !query 62 output 1 3 2 2 3 NULL 4 NULL --- !query 58 +-- !query 63 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 58 schema +-- !query 63 schema struct --- !query 58 output +-- !query 63 output 1 3 2 2 3 NULL 4 NULL --- !query 59 +-- !query 64 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 59 schema +-- !query 64 schema struct --- !query 59 output +-- !query 64 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 60 +-- !query 65 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 60 schema +-- !query 65 schema struct --- !query 60 output +-- !query 65 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 61 +-- !query 66 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 61 schema +-- !query 66 schema struct --- !query 61 output +-- !query 66 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 62 +-- !query 67 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 62 schema +-- !query 67 schema struct --- !query 62 output +-- !query 67 output 3 5 6.01 --- !query 63 +-- !query 68 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 63 schema +-- !query 68 schema struct --- !query 63 output +-- !query 68 output 1 2 2 1 3 0 4 0 --- !query 64 +-- !query 69 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 64 schema +-- !query 69 schema struct --- !query 64 output +-- !query 69 output 1 4 2 3 3 2 4 1 --- !query 65 +-- !query 70 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 65 schema +-- !query 70 schema struct --- !query 65 output +-- !query 70 output 0.0 11266.666666666666 13868.750000000002 @@ -21051,12 +21106,12 @@ struct --- !query 66 output +-- !query 71 output 0.0 11266.666666666666 13868.750000000002 @@ -21064,12 +21119,12 @@ struct --- !query 67 output +-- !query 72 output 0.0 11266.666666666666 13868.750000000002 @@ -21077,12 +21132,12 @@ struct --- !query 68 output +-- !query 73 output 0.0 11266.666666666666 13868.750000000002 @@ -21090,12 +21145,12 @@ struct --- !query 69 output +-- !query 74 output 16900.0 18491.666666666668 27129.999999999996 @@ -21103,12 +21158,12 @@ struct --- !query 70 output +-- !query 75 output 16900.0 18491.666666666668 27129.999999999996 @@ -21116,12 +21171,12 @@ struct --- !query 71 output +-- !query 76 output 16900.0 18491.666666666668 27129.999999999996 @@ -21129,12 +21184,12 @@ struct --- !query 72 output +-- !query 77 output 16900.0 18491.666666666668 27129.999999999996 @@ -21142,12 +21197,12 @@ struct --- !query 73 output +-- !query 78 output 16900.0 18491.666666666668 27129.999999999996 @@ -21155,12 +21210,12 @@ struct --- !query 74 output +-- !query 79 output 16900.0 18491.666666666668 27129.999999999996 @@ -21168,12 +21223,12 @@ struct --- !query 75 output +-- !query 80 output 16900.0 18491.666666666668 27129.999999999996 @@ -21181,12 +21236,12 @@ struct --- !query 76 output +-- !query 81 output 16900.0 18491.666666666668 27129.999999999996 @@ -21194,12 +21249,12 @@ struct --- !query 77 output +-- !query 82 output 0.0 106.14455552060438 117.76565713313879 @@ -21208,12 +21263,12 @@ struct --- !query 78 output +-- !query 83 output 0.0 106.14455552060438 117.76565713313879 @@ -21222,12 +21277,12 @@ struct --- !query 79 output +-- !query 84 output 0.0 106.14455552060438 117.76565713313879 @@ -21236,12 +21291,12 @@ struct --- !query 80 output +-- !query 85 output 0.0 106.14455552060438 117.76565713313879 @@ -21250,12 +21305,12 @@ struct --- !query 81 output +-- !query 86 output 130.0 135.9840676942217 164.7118696390761 @@ -21264,12 +21319,12 @@ struct --- !query 82 output +-- !query 87 output 130.0 135.9840676942217 164.7118696390761 @@ -21278,12 +21333,12 @@ struct --- !query 83 output +-- !query 88 output 130.0 135.9840676942217 164.7118696390761 @@ -21292,12 +21347,12 @@ struct --- !query 84 output +-- !query 89 output 130.0 135.9840676942217 164.7118696390761 @@ -21306,12 +21361,12 @@ struct --- !query 85 output +-- !query 90 output 130.0 135.9840676942217 164.7118696390761 @@ -21320,12 +21375,12 @@ struct --- !query 86 output +-- !query 91 output 130.0 135.9840676942217 164.7118696390761 @@ -21334,12 +21389,12 @@ struct --- !query 87 output +-- !query 92 output 130.0 135.9840676942217 164.7118696390761 @@ -21348,12 +21403,12 @@ struct --- !query 88 output +-- !query 93 output 130.0 135.9840676942217 164.7118696390761 @@ -21362,53 +21417,61 @@ struct --- !query 89 output +-- !query 94 output 1 1 2 2 3 NULL 4 NULL --- !query 90 +-- !query 95 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 90 schema +-- !query 95 schema struct --- !query 90 output +-- !query 95 output 1 3 2 2 3 NULL 4 NULL --- !query 91 +-- !query 96 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 91 schema +-- !query 96 schema struct --- !query 91 output +-- !query 96 output 1 3 2 6 3 9 4 7 --- !query 92 +-- !query 97 drop table empsalary --- !query 92 schema +-- !query 97 schema struct<> --- !query 92 output +-- !query 97 output --- !query 93 +-- !query 98 drop table t1 --- !query 93 schema +-- !query 98 schema struct<> --- !query 93 output +-- !query 98 output + + + +-- !query 99 +drop view int4_tbl +-- !query 99 schema +struct<> +-- !query 99 output diff --git a/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out b/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out index f22cb7e200e6c..56e781ac02d2e 100644 --- a/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out @@ -71,6 +71,7 @@ show_t1 show_t2 show_t3 tenk1 +tenk2 testdata @@ -87,6 +88,7 @@ show_t1 show_t2 show_t3 tenk1 +tenk2 testdata From 68695c0cdf8e7a29e34a612132efdec51512c117 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 20 Jun 2019 09:03:49 -0300 Subject: [PATCH 06/25] update golden files Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 2 +- .../sql-tests/results/pgSQL/window.sql.out | 230 +++++++++--------- 2 files changed, 120 insertions(+), 112 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 30456cd7922fa..6e9eb69915def 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -617,7 +617,7 @@ from range(-9223372036854775806, -9223372036854775804) x; -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); -- with UNION --- [ERROR] SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index ab50f91d25e79..dd236daa4383b 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 100 +-- Number of queries: 101 -- !query 0 @@ -889,15 +889,15 @@ struct +struct -- !query 51 output -- !query 52 -insert into t1 values (1,1),(1,2),(2,2) +create table t1 (f1 int, f2 int) using parquet -- !query 52 schema struct<> -- !query 52 output @@ -905,19 +905,27 @@ struct<> -- !query 53 -SELECT rank() OVER (ORDER BY length('abc')) +insert into t1 values (1,1),(1,2),(2,2) -- !query 53 schema -struct +struct<> -- !query 53 output -1 + -- !query 54 -SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1) +SELECT rank() OVER (ORDER BY length('abc')) -- !query 54 schema -struct +struct -- !query 54 output 1 + + +-- !query 55 +SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1) +-- !query 55 schema +struct +-- !query 55 output +1 10 100 1000 @@ -10919,11 +10927,11 @@ struct --- !query 55 output +-- !query 56 output 0 0 0 @@ -20926,18 +20934,6 @@ struct --- !query 56 output -1 1.5 -2 2.0 -3 NULL -4 NULL - - -- !query 57 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) @@ -20964,36 +20960,36 @@ struct +struct -- !query 59 output -1 2 -2 2.5 +1 1.5 +2 2.0 3 NULL 4 NULL -- !query 60 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) -- !query 60 schema -struct +struct -- !query 60 output -1 NULL -2 NULL +1 2 +2 2.5 3 NULL 4 NULL -- !query 61 -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) -- !query 61 schema -struct +struct -- !query 61 output -1 3 -2 2 +1 NULL +2 NULL 3 NULL 4 NULL @@ -21024,88 +21020,87 @@ struct +struct -- !query 64 output -1 3.3000000000000003 -2 2.2 +1 3 +2 2 3 NULL 4 NULL -- !query 65 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) -- !query 65 schema struct -- !query 65 output +1 3.3000000000000003 +2 2.2 +3 NULL +4 NULL + + +-- !query 66 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- !query 66 schema +struct +-- !query 66 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 66 +-- !query 67 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 66 schema +-- !query 67 schema struct --- !query 66 output +-- !query 67 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 67 +-- !query 68 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 67 schema +-- !query 68 schema struct --- !query 67 output +-- !query 68 output 3 5 6.01 --- !query 68 +-- !query 69 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 68 schema +-- !query 69 schema struct --- !query 68 output +-- !query 69 output 1 2 2 1 3 0 4 0 --- !query 69 +-- !query 70 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 69 schema +-- !query 70 schema struct --- !query 69 output +-- !query 70 output 1 4 2 3 3 2 4 1 --- !query 70 -SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 70 schema -struct --- !query 70 output -0.0 -11266.666666666666 -13868.750000000002 -21703.999999999996 -4225.0 - - -- !query 71 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) @@ -21146,16 +21141,16 @@ struct +struct -- !query 74 output -16900.0 -18491.666666666668 -27129.999999999996 -8450.0 -NaN +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 -- !query 75 @@ -21198,7 +21193,7 @@ NaN -- !query 78 -SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 78 schema struct @@ -21250,17 +21245,16 @@ NaN -- !query 82 -SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 82 schema -struct +struct -- !query 82 output -0.0 -106.14455552060438 -117.76565713313879 -147.32277488562315 -147.32277488562315 -65.0 +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN -- !query 83 @@ -21306,17 +21300,17 @@ struct +struct -- !query 86 output -130.0 -135.9840676942217 -164.7118696390761 -164.7118696390761 -91.92388155425118 -NaN +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 -- !query 87 @@ -21362,8 +21356,8 @@ NaN -- !query 90 -SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) -- !query 90 schema struct -- !query 90 output @@ -21418,60 +21412,74 @@ NaN -- !query 94 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 94 schema +struct +-- !query 94 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 95 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 94 schema +-- !query 95 schema struct --- !query 94 output +-- !query 95 output 1 1 2 2 3 NULL 4 NULL --- !query 95 +-- !query 96 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 95 schema +-- !query 96 schema struct --- !query 95 output +-- !query 96 output 1 3 2 2 3 NULL 4 NULL --- !query 96 +-- !query 97 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 96 schema +-- !query 97 schema struct --- !query 96 output +-- !query 97 output 1 3 2 6 3 9 4 7 --- !query 97 +-- !query 98 drop table empsalary --- !query 97 schema +-- !query 98 schema struct<> --- !query 97 output +-- !query 98 output --- !query 98 +-- !query 99 drop table t1 --- !query 98 schema +-- !query 99 schema struct<> --- !query 98 output +-- !query 99 output --- !query 99 +-- !query 100 drop view int4_tbl --- !query 99 schema +-- !query 100 schema struct<> --- !query 99 output +-- !query 100 output From 0a1f587557ef8c10593f9e44edc885d8915f3615 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 5 Jul 2019 09:18:50 -0300 Subject: [PATCH 07/25] remove untruncated queries results Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 6 +- .../sql-tests/results/pgSQL/window.sql.out | 20278 +--------------- 2 files changed, 136 insertions(+), 20148 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 6e9eb69915def..d2ce5edd2afe2 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -679,12 +679,14 @@ SELECT rank() OVER (ORDER BY length('abc')); -- [SPARK-28086] Adds `random()` to Spark -- [ERROR] SELECT * FROM rank() OVER (ORDER BY random()); -SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); +-- The output is not truncated? +-- [ERROR] SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); -- It does not work. Maybe it is related to not defining a window? -- [ERROR] SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; -SELECT count() OVER () FROM tenk1; +-- The output is not truncated? +-- [ERROR] SELECT count() OVER () FROM tenk1; -- Ok, first I migrated a call to `generate_series()`, given by Postgres, to diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index dd236daa4383b..a585516b0c26a 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 101 +-- Number of queries: 99 -- !query 0 @@ -921,20192 +921,178 @@ struct --- !query 55 output -1 -10 -100 -1000 -10000 -1001 -1002 -1003 -1004 -1005 -1006 -1007 -1008 -1009 -101 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -102 -1020 -1021 -1022 -1023 -1024 -1025 -1026 -1027 -1028 -1029 -103 -1030 -1031 -1032 -1033 -1034 -1035 -1036 -1037 -1038 -1039 -104 -1040 -1041 -1042 -1043 -1044 -1045 -1046 -1047 -1048 -1049 -105 -1050 -1051 -1052 -1053 -1054 -1055 -1056 -1057 -1058 -1059 -106 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -107 -1070 -1071 -1072 -1073 -1074 -1075 -1076 -1077 -1078 -1079 -108 -1080 -1081 -1082 -1083 -1084 -1085 -1086 -1087 -1088 -1089 -109 -1090 -1091 -1092 -1093 -1094 -1095 -1096 -1097 -1098 -1099 -11 -110 -1100 -1101 -1102 -1103 -1104 -1105 -1106 -1107 -1108 -1109 -111 -1110 -1111 -1112 -1113 -1114 -1115 -1116 -1117 -1118 -1119 -112 -1120 -1121 -1122 -1123 -1124 -1125 -1126 -1127 -1128 -1129 -113 -1130 -1131 -1132 -1133 -1134 -1135 -1136 -1137 -1138 -1139 -114 -1140 -1141 -1142 -1143 -1144 -1145 -1146 -1147 -1148 -1149 -115 -1150 -1151 -1152 -1153 -1154 -1155 -1156 -1157 -1158 -1159 -116 -1160 -1161 -1162 -1163 -1164 -1165 -1166 -1167 -1168 -1169 -117 -1170 -1171 -1172 -1173 -1174 -1175 -1176 -1177 -1178 -1179 -118 -1180 -1181 -1182 -1183 -1184 -1185 -1186 -1187 -1188 -1189 -119 -1190 -1191 -1192 -1193 -1194 -1195 -1196 -1197 -1198 -1199 -12 -120 -1200 -1201 -1202 -1203 -1204 -1205 -1206 -1207 -1208 -1209 -121 -1210 -1211 -1212 -1213 -1214 -1215 -1216 -1217 -1218 -1219 -122 -1220 -1221 -1222 -1223 -1224 -1225 -1226 -1227 -1228 -1229 -123 -1230 -1231 -1232 -1233 -1234 -1235 -1236 -1237 -1238 -1239 -124 -1240 -1241 -1242 -1243 -1244 -1245 -1246 -1247 -1248 -1249 -125 -1250 -1251 -1252 -1253 -1254 -1255 -1256 -1257 -1258 -1259 -126 -1260 -1261 -1262 -1263 -1264 -1265 -1266 -1267 -1268 -1269 -127 -1270 -1271 -1272 -1273 -1274 -1275 -1276 -1277 -1278 -1279 -128 -1280 -1281 -1282 -1283 -1284 -1285 -1286 -1287 -1288 -1289 -129 -1290 -1291 -1292 -1293 -1294 -1295 -1296 -1297 -1298 -1299 -13 -130 -1300 -1301 -1302 -1303 -1304 -1305 -1306 -1307 -1308 -1309 -131 -1310 -1311 -1312 -1313 -1314 -1315 -1316 -1317 -1318 -1319 -132 -1320 -1321 -1322 -1323 -1324 -1325 -1326 -1327 -1328 -1329 -133 -1330 -1331 -1332 -1333 -1334 -1335 -1336 -1337 -1338 -1339 -134 -1340 -1341 -1342 -1343 -1344 -1345 -1346 -1347 -1348 -1349 -135 -1350 -1351 -1352 -1353 -1354 -1355 -1356 -1357 -1358 -1359 -136 -1360 -1361 -1362 -1363 -1364 -1365 -1366 -1367 -1368 -1369 -137 -1370 -1371 -1372 -1373 -1374 -1375 -1376 -1377 -1378 -1379 -138 -1380 -1381 -1382 -1383 -1384 -1385 -1386 -1387 -1388 -1389 -139 -1390 -1391 -1392 -1393 -1394 -1395 -1396 -1397 -1398 -1399 -14 -140 -1400 -1401 -1402 -1403 -1404 -1405 -1406 -1407 -1408 -1409 -141 -1410 -1411 -1412 -1413 -1414 -1415 -1416 -1417 -1418 -1419 -142 -1420 -1421 -1422 -1423 -1424 -1425 -1426 -1427 -1428 -1429 -143 -1430 -1431 -1432 -1433 -1434 -1435 -1436 -1437 -1438 -1439 -144 -1440 -1441 -1442 -1443 -1444 -1445 -1446 -1447 -1448 -1449 -145 -1450 -1451 -1452 -1453 -1454 -1455 -1456 -1457 -1458 -1459 -146 -1460 -1461 -1462 -1463 -1464 -1465 -1466 -1467 -1468 -1469 -147 -1470 -1471 -1472 -1473 -1474 -1475 -1476 -1477 -1478 -1479 -148 -1480 -1481 -1482 -1483 -1484 -1485 -1486 -1487 -1488 -1489 -149 -1490 -1491 -1492 -1493 -1494 -1495 -1496 -1497 -1498 -1499 -15 -150 -1500 -1501 -1502 -1503 -1504 -1505 -1506 -1507 -1508 -1509 -151 -1510 -1511 -1512 -1513 -1514 -1515 -1516 -1517 -1518 -1519 -152 -1520 -1521 -1522 -1523 -1524 -1525 -1526 -1527 -1528 -1529 -153 -1530 -1531 -1532 -1533 -1534 -1535 -1536 -1537 -1538 -1539 -154 -1540 -1541 -1542 -1543 -1544 -1545 -1546 -1547 -1548 -1549 -155 -1550 -1551 -1552 -1553 -1554 -1555 -1556 -1557 -1558 -1559 -156 -1560 -1561 -1562 -1563 -1564 -1565 -1566 -1567 -1568 -1569 -157 -1570 -1571 -1572 -1573 -1574 -1575 -1576 -1577 -1578 -1579 -158 -1580 -1581 -1582 -1583 -1584 -1585 -1586 -1587 -1588 -1589 -159 -1590 -1591 -1592 -1593 -1594 -1595 -1596 -1597 -1598 -1599 -16 -160 -1600 -1601 -1602 -1603 -1604 -1605 -1606 -1607 -1608 -1609 -161 -1610 -1611 -1612 -1613 -1614 -1615 -1616 -1617 -1618 -1619 -162 -1620 -1621 -1622 -1623 -1624 -1625 -1626 -1627 -1628 -1629 -163 -1630 -1631 -1632 -1633 -1634 -1635 -1636 -1637 -1638 -1639 -164 -1640 -1641 -1642 -1643 -1644 -1645 -1646 -1647 -1648 -1649 -165 -1650 -1651 -1652 -1653 -1654 -1655 -1656 -1657 -1658 -1659 -166 -1660 -1661 -1662 -1663 -1664 -1665 -1666 -1667 -1668 -1669 -167 -1670 -1671 -1672 -1673 -1674 -1675 -1676 -1677 -1678 -1679 -168 -1680 -1681 -1682 -1683 -1684 -1685 -1686 -1687 -1688 -1689 -169 -1690 -1691 -1692 -1693 -1694 -1695 -1696 -1697 -1698 -1699 -17 -170 -1700 -1701 -1702 -1703 -1704 -1705 -1706 -1707 -1708 -1709 -171 -1710 -1711 -1712 -1713 -1714 -1715 -1716 -1717 -1718 -1719 -172 -1720 -1721 -1722 -1723 -1724 -1725 -1726 -1727 -1728 -1729 -173 -1730 -1731 -1732 -1733 -1734 -1735 -1736 -1737 -1738 -1739 -174 -1740 -1741 -1742 -1743 -1744 -1745 -1746 -1747 -1748 -1749 -175 -1750 -1751 -1752 -1753 -1754 -1755 -1756 -1757 -1758 -1759 -176 -1760 -1761 -1762 -1763 -1764 -1765 -1766 -1767 -1768 -1769 -177 -1770 -1771 -1772 -1773 -1774 -1775 -1776 -1777 -1778 -1779 -178 -1780 -1781 -1782 -1783 -1784 -1785 -1786 -1787 -1788 -1789 -179 -1790 -1791 -1792 -1793 -1794 -1795 -1796 -1797 -1798 -1799 -18 -180 -1800 -1801 -1802 -1803 -1804 -1805 -1806 -1807 -1808 -1809 -181 -1810 -1811 -1812 -1813 -1814 -1815 -1816 -1817 -1818 -1819 -182 -1820 -1821 -1822 -1823 -1824 -1825 -1826 -1827 -1828 -1829 -183 -1830 -1831 -1832 -1833 -1834 -1835 -1836 -1837 -1838 -1839 -184 -1840 -1841 -1842 -1843 -1844 -1845 -1846 -1847 -1848 -1849 -185 -1850 -1851 -1852 -1853 -1854 -1855 -1856 -1857 -1858 -1859 -186 -1860 -1861 -1862 -1863 -1864 -1865 -1866 -1867 -1868 -1869 -187 -1870 -1871 -1872 -1873 -1874 -1875 -1876 -1877 -1878 -1879 -188 -1880 -1881 -1882 -1883 -1884 -1885 -1886 -1887 -1888 -1889 -189 -1890 -1891 -1892 -1893 -1894 -1895 -1896 -1897 -1898 -1899 -19 -190 -1900 -1901 -1902 -1903 -1904 -1905 -1906 -1907 -1908 -1909 -191 -1910 -1911 -1912 -1913 -1914 -1915 -1916 -1917 -1918 -1919 -192 -1920 -1921 -1922 -1923 -1924 -1925 -1926 -1927 -1928 -1929 -193 -1930 -1931 -1932 -1933 -1934 -1935 -1936 -1937 -1938 -1939 -194 -1940 -1941 -1942 -1943 -1944 -1945 -1946 -1947 -1948 -1949 -195 -1950 -1951 -1952 -1953 -1954 -1955 -1956 -1957 -1958 -1959 -196 -1960 -1961 -1962 -1963 -1964 -1965 -1966 -1967 -1968 -1969 -197 -1970 -1971 -1972 -1973 -1974 -1975 -1976 -1977 -1978 -1979 -198 -1980 -1981 -1982 -1983 -1984 -1985 -1986 -1987 -1988 -1989 -199 -1990 -1991 -1992 -1993 -1994 -1995 -1996 -1997 -1998 -1999 -2 -20 -200 -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 -2009 -201 -2010 -2011 -2012 -2013 -2014 -2015 -2016 -2017 -2018 -2019 -202 -2020 -2021 -2022 -2023 -2024 -2025 -2026 -2027 -2028 -2029 -203 -2030 -2031 -2032 -2033 -2034 -2035 -2036 -2037 -2038 -2039 -204 -2040 -2041 -2042 -2043 -2044 -2045 -2046 -2047 -2048 -2049 -205 -2050 -2051 -2052 -2053 -2054 -2055 -2056 -2057 -2058 -2059 -206 -2060 -2061 -2062 -2063 -2064 -2065 -2066 -2067 -2068 -2069 -207 -2070 -2071 -2072 -2073 -2074 -2075 -2076 -2077 -2078 -2079 -208 -2080 -2081 -2082 -2083 -2084 -2085 -2086 -2087 -2088 -2089 -209 -2090 -2091 -2092 -2093 -2094 -2095 -2096 -2097 -2098 -2099 -21 -210 -2100 -2101 -2102 -2103 -2104 -2105 -2106 -2107 -2108 -2109 -211 -2110 -2111 -2112 -2113 -2114 -2115 -2116 -2117 -2118 -2119 -212 -2120 -2121 -2122 -2123 -2124 -2125 -2126 -2127 -2128 -2129 -213 -2130 -2131 -2132 -2133 -2134 -2135 -2136 -2137 -2138 -2139 -214 -2140 -2141 -2142 -2143 -2144 -2145 -2146 -2147 -2148 -2149 -215 -2150 -2151 -2152 -2153 -2154 -2155 -2156 -2157 -2158 -2159 -216 -2160 -2161 -2162 -2163 -2164 -2165 -2166 -2167 -2168 -2169 -217 -2170 -2171 -2172 -2173 -2174 -2175 -2176 -2177 -2178 -2179 -218 -2180 -2181 -2182 -2183 -2184 -2185 -2186 -2187 -2188 -2189 -219 -2190 -2191 -2192 -2193 -2194 -2195 -2196 -2197 -2198 -2199 -22 -220 -2200 -2201 -2202 -2203 -2204 -2205 -2206 -2207 -2208 -2209 -221 -2210 -2211 -2212 -2213 -2214 -2215 -2216 -2217 -2218 -2219 -222 -2220 -2221 -2222 -2223 -2224 -2225 -2226 -2227 -2228 -2229 -223 -2230 -2231 -2232 -2233 -2234 -2235 -2236 -2237 -2238 -2239 -224 -2240 -2241 -2242 -2243 -2244 -2245 -2246 -2247 -2248 -2249 -225 -2250 -2251 -2252 -2253 -2254 -2255 -2256 -2257 -2258 -2259 -226 -2260 -2261 -2262 -2263 -2264 -2265 -2266 -2267 -2268 -2269 -227 -2270 -2271 -2272 -2273 -2274 -2275 -2276 -2277 -2278 -2279 -228 -2280 -2281 -2282 -2283 -2284 -2285 -2286 -2287 -2288 -2289 -229 -2290 -2291 -2292 -2293 -2294 -2295 -2296 -2297 -2298 -2299 -23 -230 -2300 -2301 -2302 -2303 -2304 -2305 -2306 -2307 -2308 -2309 -231 -2310 -2311 -2312 -2313 -2314 -2315 -2316 -2317 -2318 -2319 -232 -2320 -2321 -2322 -2323 -2324 -2325 -2326 -2327 -2328 -2329 -233 -2330 -2331 -2332 -2333 -2334 -2335 -2336 -2337 -2338 -2339 -234 -2340 -2341 -2342 -2343 -2344 -2345 -2346 -2347 -2348 -2349 -235 -2350 -2351 -2352 -2353 -2354 -2355 -2356 -2357 -2358 -2359 -236 -2360 -2361 -2362 -2363 -2364 -2365 -2366 -2367 -2368 -2369 -237 -2370 -2371 -2372 -2373 -2374 -2375 -2376 -2377 -2378 -2379 -238 -2380 -2381 -2382 -2383 -2384 -2385 -2386 -2387 -2388 -2389 -239 -2390 -2391 -2392 -2393 -2394 -2395 -2396 -2397 -2398 -2399 -24 -240 -2400 -2401 -2402 -2403 -2404 -2405 -2406 -2407 -2408 -2409 -241 -2410 -2411 -2412 -2413 -2414 -2415 -2416 -2417 -2418 -2419 -242 -2420 -2421 -2422 -2423 -2424 -2425 -2426 -2427 -2428 -2429 -243 -2430 -2431 -2432 -2433 -2434 -2435 -2436 -2437 -2438 -2439 -244 -2440 -2441 -2442 -2443 -2444 -2445 -2446 -2447 -2448 -2449 -245 -2450 -2451 -2452 -2453 -2454 -2455 -2456 -2457 -2458 -2459 -246 -2460 -2461 -2462 -2463 -2464 -2465 -2466 -2467 -2468 -2469 -247 -2470 -2471 -2472 -2473 -2474 -2475 -2476 -2477 -2478 -2479 -248 -2480 -2481 -2482 -2483 -2484 -2485 -2486 -2487 -2488 -2489 -249 -2490 -2491 -2492 -2493 -2494 -2495 -2496 -2497 -2498 -2499 -25 -250 -2500 -2501 -2502 -2503 -2504 -2505 -2506 -2507 -2508 -2509 -251 -2510 -2511 -2512 -2513 -2514 -2515 -2516 -2517 -2518 -2519 -252 -2520 -2521 -2522 -2523 -2524 -2525 -2526 -2527 -2528 -2529 -253 -2530 -2531 -2532 -2533 -2534 -2535 -2536 -2537 -2538 -2539 -254 -2540 -2541 -2542 -2543 -2544 -2545 -2546 -2547 -2548 -2549 -255 -2550 -2551 -2552 -2553 -2554 -2555 -2556 -2557 -2558 -2559 -256 -2560 -2561 -2562 -2563 -2564 -2565 -2566 -2567 -2568 -2569 -257 -2570 -2571 -2572 -2573 -2574 -2575 -2576 -2577 -2578 -2579 -258 -2580 -2581 -2582 -2583 -2584 -2585 -2586 -2587 -2588 -2589 -259 -2590 -2591 -2592 -2593 -2594 -2595 -2596 -2597 -2598 -2599 -26 -260 -2600 -2601 -2602 -2603 -2604 -2605 -2606 -2607 -2608 -2609 -261 -2610 -2611 -2612 -2613 -2614 -2615 -2616 -2617 -2618 -2619 -262 -2620 -2621 -2622 -2623 -2624 -2625 -2626 -2627 -2628 -2629 -263 -2630 -2631 -2632 -2633 -2634 -2635 -2636 -2637 -2638 -2639 -264 -2640 -2641 -2642 -2643 -2644 -2645 -2646 -2647 -2648 -2649 -265 -2650 -2651 -2652 -2653 -2654 -2655 -2656 -2657 -2658 -2659 -266 -2660 -2661 -2662 -2663 -2664 -2665 -2666 -2667 -2668 -2669 -267 -2670 -2671 -2672 -2673 -2674 -2675 -2676 -2677 -2678 -2679 -268 -2680 -2681 -2682 -2683 -2684 -2685 -2686 -2687 -2688 -2689 -269 -2690 -2691 -2692 -2693 -2694 -2695 -2696 -2697 -2698 -2699 -27 -270 -2700 -2701 -2702 -2703 -2704 -2705 -2706 -2707 -2708 -2709 -271 -2710 -2711 -2712 -2713 -2714 -2715 -2716 -2717 -2718 -2719 -272 -2720 -2721 -2722 -2723 -2724 -2725 -2726 -2727 -2728 -2729 -273 -2730 -2731 -2732 -2733 -2734 -2735 -2736 -2737 -2738 -2739 -274 -2740 -2741 -2742 -2743 -2744 -2745 -2746 -2747 -2748 -2749 -275 -2750 -2751 -2752 -2753 -2754 -2755 -2756 -2757 -2758 -2759 -276 -2760 -2761 -2762 -2763 -2764 -2765 -2766 -2767 -2768 -2769 -277 -2770 -2771 -2772 -2773 -2774 -2775 -2776 -2777 -2778 -2779 -278 -2780 -2781 -2782 -2783 -2784 -2785 -2786 -2787 -2788 -2789 -279 -2790 -2791 -2792 -2793 -2794 -2795 -2796 -2797 -2798 -2799 -28 -280 -2800 -2801 -2802 -2803 -2804 -2805 -2806 -2807 -2808 -2809 -281 -2810 -2811 -2812 -2813 -2814 -2815 -2816 -2817 -2818 -2819 -282 -2820 -2821 -2822 -2823 -2824 -2825 -2826 -2827 -2828 -2829 -283 -2830 -2831 -2832 -2833 -2834 -2835 -2836 -2837 -2838 -2839 -284 -2840 -2841 -2842 -2843 -2844 -2845 -2846 -2847 -2848 -2849 -285 -2850 -2851 -2852 -2853 -2854 -2855 -2856 -2857 -2858 -2859 -286 -2860 -2861 -2862 -2863 -2864 -2865 -2866 -2867 -2868 -2869 -287 -2870 -2871 -2872 -2873 -2874 -2875 -2876 -2877 -2878 -2879 -288 -2880 -2881 -2882 -2883 -2884 -2885 -2886 -2887 -2888 -2889 -289 -2890 -2891 -2892 -2893 -2894 -2895 -2896 -2897 -2898 -2899 -29 -290 -2900 -2901 -2902 -2903 -2904 -2905 -2906 -2907 -2908 -2909 -291 -2910 -2911 -2912 -2913 -2914 -2915 -2916 -2917 -2918 -2919 -292 -2920 -2921 -2922 -2923 -2924 -2925 -2926 -2927 -2928 -2929 -293 -2930 -2931 -2932 -2933 -2934 -2935 -2936 -2937 -2938 -2939 -294 -2940 -2941 -2942 -2943 -2944 -2945 -2946 -2947 -2948 -2949 -295 -2950 -2951 -2952 -2953 -2954 -2955 -2956 -2957 -2958 -2959 -296 -2960 -2961 -2962 -2963 -2964 -2965 -2966 -2967 -2968 -2969 -297 -2970 -2971 -2972 -2973 -2974 -2975 -2976 -2977 -2978 -2979 -298 -2980 -2981 -2982 -2983 -2984 -2985 -2986 -2987 -2988 -2989 -299 -2990 -2991 -2992 -2993 -2994 -2995 -2996 -2997 -2998 -2999 -3 -30 -300 -3000 -3001 -3002 -3003 -3004 -3005 -3006 -3007 -3008 -3009 -301 -3010 -3011 -3012 -3013 -3014 -3015 -3016 -3017 -3018 -3019 -302 -3020 -3021 -3022 -3023 -3024 -3025 -3026 -3027 -3028 -3029 -303 -3030 -3031 -3032 -3033 -3034 -3035 -3036 -3037 -3038 -3039 -304 -3040 -3041 -3042 -3043 -3044 -3045 -3046 -3047 -3048 -3049 -305 -3050 -3051 -3052 -3053 -3054 -3055 -3056 -3057 -3058 -3059 -306 -3060 -3061 -3062 -3063 -3064 -3065 -3066 -3067 -3068 -3069 -307 -3070 -3071 -3072 -3073 -3074 -3075 -3076 -3077 -3078 -3079 -308 -3080 -3081 -3082 -3083 -3084 -3085 -3086 -3087 -3088 -3089 -309 -3090 -3091 -3092 -3093 -3094 -3095 -3096 -3097 -3098 -3099 -31 -310 -3100 -3101 -3102 -3103 -3104 -3105 -3106 -3107 -3108 -3109 -311 -3110 -3111 -3112 -3113 -3114 -3115 -3116 -3117 -3118 -3119 -312 -3120 -3121 -3122 -3123 -3124 -3125 -3126 -3127 -3128 -3129 -313 -3130 -3131 -3132 -3133 -3134 -3135 -3136 -3137 -3138 -3139 -314 -3140 -3141 -3142 -3143 -3144 -3145 -3146 -3147 -3148 -3149 -315 -3150 -3151 -3152 -3153 -3154 -3155 -3156 -3157 -3158 -3159 -316 -3160 -3161 -3162 -3163 -3164 -3165 -3166 -3167 -3168 -3169 -317 -3170 -3171 -3172 -3173 -3174 -3175 -3176 -3177 -3178 -3179 -318 -3180 -3181 -3182 -3183 -3184 -3185 -3186 -3187 -3188 -3189 -319 -3190 -3191 -3192 -3193 -3194 -3195 -3196 -3197 -3198 -3199 -32 -320 -3200 -3201 -3202 -3203 -3204 -3205 -3206 -3207 -3208 -3209 -321 -3210 -3211 -3212 -3213 -3214 -3215 -3216 -3217 -3218 -3219 -322 -3220 -3221 -3222 -3223 -3224 -3225 -3226 -3227 -3228 -3229 -323 -3230 -3231 -3232 -3233 -3234 -3235 -3236 -3237 -3238 -3239 -324 -3240 -3241 -3242 -3243 -3244 -3245 -3246 -3247 -3248 -3249 -325 -3250 -3251 -3252 -3253 -3254 -3255 -3256 -3257 -3258 -3259 -326 -3260 -3261 -3262 -3263 -3264 -3265 -3266 -3267 -3268 -3269 -327 -3270 -3271 -3272 -3273 -3274 -3275 -3276 -3277 -3278 -3279 -328 -3280 -3281 -3282 -3283 -3284 -3285 -3286 -3287 -3288 -3289 -329 -3290 -3291 -3292 -3293 -3294 -3295 -3296 -3297 -3298 -3299 -33 -330 -3300 -3301 -3302 -3303 -3304 -3305 -3306 -3307 -3308 -3309 -331 -3310 -3311 -3312 -3313 -3314 -3315 -3316 -3317 -3318 -3319 -332 -3320 -3321 -3322 -3323 -3324 -3325 -3326 -3327 -3328 -3329 -333 -3330 -3331 -3332 -3333 -3334 -3335 -3336 -3337 -3338 -3339 -334 -3340 -3341 -3342 -3343 -3344 -3345 -3346 -3347 -3348 -3349 -335 -3350 -3351 -3352 -3353 -3354 -3355 -3356 -3357 -3358 -3359 -336 -3360 -3361 -3362 -3363 -3364 -3365 -3366 -3367 -3368 -3369 -337 -3370 -3371 -3372 -3373 -3374 -3375 -3376 -3377 -3378 -3379 -338 -3380 -3381 -3382 -3383 -3384 -3385 -3386 -3387 -3388 -3389 -339 -3390 -3391 -3392 -3393 -3394 -3395 -3396 -3397 -3398 -3399 -34 -340 -3400 -3401 -3402 -3403 -3404 -3405 -3406 -3407 -3408 -3409 -341 -3410 -3411 -3412 -3413 -3414 -3415 -3416 -3417 -3418 -3419 -342 -3420 -3421 -3422 -3423 -3424 -3425 -3426 -3427 -3428 -3429 -343 -3430 -3431 -3432 -3433 -3434 -3435 -3436 -3437 -3438 -3439 -344 -3440 -3441 -3442 -3443 -3444 -3445 -3446 -3447 -3448 -3449 -345 -3450 -3451 -3452 -3453 -3454 -3455 -3456 -3457 -3458 -3459 -346 -3460 -3461 -3462 -3463 -3464 -3465 -3466 -3467 -3468 -3469 -347 -3470 -3471 -3472 -3473 -3474 -3475 -3476 -3477 -3478 -3479 -348 -3480 -3481 -3482 -3483 -3484 -3485 -3486 -3487 -3488 -3489 -349 -3490 -3491 -3492 -3493 -3494 -3495 -3496 -3497 -3498 -3499 -35 -350 -3500 -3501 -3502 -3503 -3504 -3505 -3506 -3507 -3508 -3509 -351 -3510 -3511 -3512 -3513 -3514 -3515 -3516 -3517 -3518 -3519 -352 -3520 -3521 -3522 -3523 -3524 -3525 -3526 -3527 -3528 -3529 -353 -3530 -3531 -3532 -3533 -3534 -3535 -3536 -3537 -3538 -3539 -354 -3540 -3541 -3542 -3543 -3544 -3545 -3546 -3547 -3548 -3549 -355 -3550 -3551 -3552 -3553 -3554 -3555 -3556 -3557 -3558 -3559 -356 -3560 -3561 -3562 -3563 -3564 -3565 -3566 -3567 -3568 -3569 -357 -3570 -3571 -3572 -3573 -3574 -3575 -3576 -3577 -3578 -3579 -358 -3580 -3581 -3582 -3583 -3584 -3585 -3586 -3587 -3588 -3589 -359 -3590 -3591 -3592 -3593 -3594 -3595 -3596 -3597 -3598 -3599 -36 -360 -3600 -3601 -3602 -3603 -3604 -3605 -3606 -3607 -3608 -3609 -361 -3610 -3611 -3612 -3613 -3614 -3615 -3616 -3617 -3618 -3619 -362 -3620 -3621 -3622 -3623 -3624 -3625 -3626 -3627 -3628 -3629 -363 -3630 -3631 -3632 -3633 -3634 -3635 -3636 -3637 -3638 -3639 -364 -3640 -3641 -3642 -3643 -3644 -3645 -3646 -3647 -3648 -3649 -365 -3650 -3651 -3652 -3653 -3654 -3655 -3656 -3657 -3658 -3659 -366 -3660 -3661 -3662 -3663 -3664 -3665 -3666 -3667 -3668 -3669 -367 -3670 -3671 -3672 -3673 -3674 -3675 -3676 -3677 -3678 -3679 -368 -3680 -3681 -3682 -3683 -3684 -3685 -3686 -3687 -3688 -3689 -369 -3690 -3691 -3692 -3693 -3694 -3695 -3696 -3697 -3698 -3699 -37 -370 -3700 -3701 -3702 -3703 -3704 -3705 -3706 -3707 -3708 -3709 -371 -3710 -3711 -3712 -3713 -3714 -3715 -3716 -3717 -3718 -3719 -372 -3720 -3721 -3722 -3723 -3724 -3725 -3726 -3727 -3728 -3729 -373 -3730 -3731 -3732 -3733 -3734 -3735 -3736 -3737 -3738 -3739 -374 -3740 -3741 -3742 -3743 -3744 -3745 -3746 -3747 -3748 -3749 -375 -3750 -3751 -3752 -3753 -3754 -3755 -3756 -3757 -3758 -3759 -376 -3760 -3761 -3762 -3763 -3764 -3765 -3766 -3767 -3768 -3769 -377 -3770 -3771 -3772 -3773 -3774 -3775 -3776 -3777 -3778 -3779 -378 -3780 -3781 -3782 -3783 -3784 -3785 -3786 -3787 -3788 -3789 -379 -3790 -3791 -3792 -3793 -3794 -3795 -3796 -3797 -3798 -3799 -38 -380 -3800 -3801 -3802 -3803 -3804 -3805 -3806 -3807 -3808 -3809 -381 -3810 -3811 -3812 -3813 -3814 -3815 -3816 -3817 -3818 -3819 -382 -3820 -3821 -3822 -3823 -3824 -3825 -3826 -3827 -3828 -3829 -383 -3830 -3831 -3832 -3833 -3834 -3835 -3836 -3837 -3838 -3839 -384 -3840 -3841 -3842 -3843 -3844 -3845 -3846 -3847 -3848 -3849 -385 -3850 -3851 -3852 -3853 -3854 -3855 -3856 -3857 -3858 -3859 -386 -3860 -3861 -3862 -3863 -3864 -3865 -3866 -3867 -3868 -3869 -387 -3870 -3871 -3872 -3873 -3874 -3875 -3876 -3877 -3878 -3879 -388 -3880 -3881 -3882 -3883 -3884 -3885 -3886 -3887 -3888 -3889 -389 -3890 -3891 -3892 -3893 -3894 -3895 -3896 -3897 -3898 -3899 -39 -390 -3900 -3901 -3902 -3903 -3904 -3905 -3906 -3907 -3908 -3909 -391 -3910 -3911 -3912 -3913 -3914 -3915 -3916 -3917 -3918 -3919 -392 -3920 -3921 -3922 -3923 -3924 -3925 -3926 -3927 -3928 -3929 -393 -3930 -3931 -3932 -3933 -3934 -3935 -3936 -3937 -3938 -3939 -394 -3940 -3941 -3942 -3943 -3944 -3945 -3946 -3947 -3948 -3949 -395 -3950 -3951 -3952 -3953 -3954 -3955 -3956 -3957 -3958 -3959 -396 -3960 -3961 -3962 -3963 -3964 -3965 -3966 -3967 -3968 -3969 -397 -3970 -3971 -3972 -3973 -3974 -3975 -3976 -3977 -3978 -3979 -398 -3980 -3981 -3982 -3983 -3984 -3985 -3986 -3987 -3988 -3989 -399 -3990 -3991 -3992 -3993 -3994 -3995 -3996 -3997 -3998 -3999 -4 -40 -400 -4000 -4001 -4002 -4003 -4004 -4005 -4006 -4007 -4008 -4009 -401 -4010 -4011 -4012 -4013 -4014 -4015 -4016 -4017 -4018 -4019 -402 -4020 -4021 -4022 -4023 -4024 -4025 -4026 -4027 -4028 -4029 -403 -4030 -4031 -4032 -4033 -4034 -4035 -4036 -4037 -4038 -4039 -404 -4040 -4041 -4042 -4043 -4044 -4045 -4046 -4047 -4048 -4049 -405 -4050 -4051 -4052 -4053 -4054 -4055 -4056 -4057 -4058 -4059 -406 -4060 -4061 -4062 -4063 -4064 -4065 -4066 -4067 -4068 -4069 -407 -4070 -4071 -4072 -4073 -4074 -4075 -4076 -4077 -4078 -4079 -408 -4080 -4081 -4082 -4083 -4084 -4085 -4086 -4087 -4088 -4089 -409 -4090 -4091 -4092 -4093 -4094 -4095 -4096 -4097 -4098 -4099 -41 -410 -4100 -4101 -4102 -4103 -4104 -4105 -4106 -4107 -4108 -4109 -411 -4110 -4111 -4112 -4113 -4114 -4115 -4116 -4117 -4118 -4119 -412 -4120 -4121 -4122 -4123 -4124 -4125 -4126 -4127 -4128 -4129 -413 -4130 -4131 -4132 -4133 -4134 -4135 -4136 -4137 -4138 -4139 -414 -4140 -4141 -4142 -4143 -4144 -4145 -4146 -4147 -4148 -4149 -415 -4150 -4151 -4152 -4153 -4154 -4155 -4156 -4157 -4158 -4159 -416 -4160 -4161 -4162 -4163 -4164 -4165 -4166 -4167 -4168 -4169 -417 -4170 -4171 -4172 -4173 -4174 -4175 -4176 -4177 -4178 -4179 -418 -4180 -4181 -4182 -4183 -4184 -4185 -4186 -4187 -4188 -4189 -419 -4190 -4191 -4192 -4193 -4194 -4195 -4196 -4197 -4198 -4199 -42 -420 -4200 -4201 -4202 -4203 -4204 -4205 -4206 -4207 -4208 -4209 -421 -4210 -4211 -4212 -4213 -4214 -4215 -4216 -4217 -4218 -4219 -422 -4220 -4221 -4222 -4223 -4224 -4225 -4226 -4227 -4228 -4229 -423 -4230 -4231 -4232 -4233 -4234 -4235 -4236 -4237 -4238 -4239 -424 -4240 -4241 -4242 -4243 -4244 -4245 -4246 -4247 -4248 -4249 -425 -4250 -4251 -4252 -4253 -4254 -4255 -4256 -4257 -4258 -4259 -426 -4260 -4261 -4262 -4263 -4264 -4265 -4266 -4267 -4268 -4269 -427 -4270 -4271 -4272 -4273 -4274 -4275 -4276 -4277 -4278 -4279 -428 -4280 -4281 -4282 -4283 -4284 -4285 -4286 -4287 -4288 -4289 -429 -4290 -4291 -4292 -4293 -4294 -4295 -4296 -4297 -4298 -4299 -43 -430 -4300 -4301 -4302 -4303 -4304 -4305 -4306 -4307 -4308 -4309 -431 -4310 -4311 -4312 -4313 -4314 -4315 -4316 -4317 -4318 -4319 -432 -4320 -4321 -4322 -4323 -4324 -4325 -4326 -4327 -4328 -4329 -433 -4330 -4331 -4332 -4333 -4334 -4335 -4336 -4337 -4338 -4339 -434 -4340 -4341 -4342 -4343 -4344 -4345 -4346 -4347 -4348 -4349 -435 -4350 -4351 -4352 -4353 -4354 -4355 -4356 -4357 -4358 -4359 -436 -4360 -4361 -4362 -4363 -4364 -4365 -4366 -4367 -4368 -4369 -437 -4370 -4371 -4372 -4373 -4374 -4375 -4376 -4377 -4378 -4379 -438 -4380 -4381 -4382 -4383 -4384 -4385 -4386 -4387 -4388 -4389 -439 -4390 -4391 -4392 -4393 -4394 -4395 -4396 -4397 -4398 -4399 -44 -440 -4400 -4401 -4402 -4403 -4404 -4405 -4406 -4407 -4408 -4409 -441 -4410 -4411 -4412 -4413 -4414 -4415 -4416 -4417 -4418 -4419 -442 -4420 -4421 -4422 -4423 -4424 -4425 -4426 -4427 -4428 -4429 -443 -4430 -4431 -4432 -4433 -4434 -4435 -4436 -4437 -4438 -4439 -444 -4440 -4441 -4442 -4443 -4444 -4445 -4446 -4447 -4448 -4449 -445 -4450 -4451 -4452 -4453 -4454 -4455 -4456 -4457 -4458 -4459 -446 -4460 -4461 -4462 -4463 -4464 -4465 -4466 -4467 -4468 -4469 -447 -4470 -4471 -4472 -4473 -4474 -4475 -4476 -4477 -4478 -4479 -448 -4480 -4481 -4482 -4483 -4484 -4485 -4486 -4487 -4488 -4489 -449 -4490 -4491 -4492 -4493 -4494 -4495 -4496 -4497 -4498 -4499 -45 -450 -4500 -4501 -4502 -4503 -4504 -4505 -4506 -4507 -4508 -4509 -451 -4510 -4511 -4512 -4513 -4514 -4515 -4516 -4517 -4518 -4519 -452 -4520 -4521 -4522 -4523 -4524 -4525 -4526 -4527 -4528 -4529 -453 -4530 -4531 -4532 -4533 -4534 -4535 -4536 -4537 -4538 -4539 -454 -4540 -4541 -4542 -4543 -4544 -4545 -4546 -4547 -4548 -4549 -455 -4550 -4551 -4552 -4553 -4554 -4555 -4556 -4557 -4558 -4559 -456 -4560 -4561 -4562 -4563 -4564 -4565 -4566 -4567 -4568 -4569 -457 -4570 -4571 -4572 -4573 -4574 -4575 -4576 -4577 -4578 -4579 -458 -4580 -4581 -4582 -4583 -4584 -4585 -4586 -4587 -4588 -4589 -459 -4590 -4591 -4592 -4593 -4594 -4595 -4596 -4597 -4598 -4599 -46 -460 -4600 -4601 -4602 -4603 -4604 -4605 -4606 -4607 -4608 -4609 -461 -4610 -4611 -4612 -4613 -4614 -4615 -4616 -4617 -4618 -4619 -462 -4620 -4621 -4622 -4623 -4624 -4625 -4626 -4627 -4628 -4629 -463 -4630 -4631 -4632 -4633 -4634 -4635 -4636 -4637 -4638 -4639 -464 -4640 -4641 -4642 -4643 -4644 -4645 -4646 -4647 -4648 -4649 -465 -4650 -4651 -4652 -4653 -4654 -4655 -4656 -4657 -4658 -4659 -466 -4660 -4661 -4662 -4663 -4664 -4665 -4666 -4667 -4668 -4669 -467 -4670 -4671 -4672 -4673 -4674 -4675 -4676 -4677 -4678 -4679 -468 -4680 -4681 -4682 -4683 -4684 -4685 -4686 -4687 -4688 -4689 -469 -4690 -4691 -4692 -4693 -4694 -4695 -4696 -4697 -4698 -4699 -47 -470 -4700 -4701 -4702 -4703 -4704 -4705 -4706 -4707 -4708 -4709 -471 -4710 -4711 -4712 -4713 -4714 -4715 -4716 -4717 -4718 -4719 -472 -4720 -4721 -4722 -4723 -4724 -4725 -4726 -4727 -4728 -4729 -473 -4730 -4731 -4732 -4733 -4734 -4735 -4736 -4737 -4738 -4739 -474 -4740 -4741 -4742 -4743 -4744 -4745 -4746 -4747 -4748 -4749 -475 -4750 -4751 -4752 -4753 -4754 -4755 -4756 -4757 -4758 -4759 -476 -4760 -4761 -4762 -4763 -4764 -4765 -4766 -4767 -4768 -4769 -477 -4770 -4771 -4772 -4773 -4774 -4775 -4776 -4777 -4778 -4779 -478 -4780 -4781 -4782 -4783 -4784 -4785 -4786 -4787 -4788 -4789 -479 -4790 -4791 -4792 -4793 -4794 -4795 -4796 -4797 -4798 -4799 -48 -480 -4800 -4801 -4802 -4803 -4804 -4805 -4806 -4807 -4808 -4809 -481 -4810 -4811 -4812 -4813 -4814 -4815 -4816 -4817 -4818 -4819 -482 -4820 -4821 -4822 -4823 -4824 -4825 -4826 -4827 -4828 -4829 -483 -4830 -4831 -4832 -4833 -4834 -4835 -4836 -4837 -4838 -4839 -484 -4840 -4841 -4842 -4843 -4844 -4845 -4846 -4847 -4848 -4849 -485 -4850 -4851 -4852 -4853 -4854 -4855 -4856 -4857 -4858 -4859 -486 -4860 -4861 -4862 -4863 -4864 -4865 -4866 -4867 -4868 -4869 -487 -4870 -4871 -4872 -4873 -4874 -4875 -4876 -4877 -4878 -4879 -488 -4880 -4881 -4882 -4883 -4884 -4885 -4886 -4887 -4888 -4889 -489 -4890 -4891 -4892 -4893 -4894 -4895 -4896 -4897 -4898 -4899 -49 -490 -4900 -4901 -4902 -4903 -4904 -4905 -4906 -4907 -4908 -4909 -491 -4910 -4911 -4912 -4913 -4914 -4915 -4916 -4917 -4918 -4919 -492 -4920 -4921 -4922 -4923 -4924 -4925 -4926 -4927 -4928 -4929 -493 -4930 -4931 -4932 -4933 -4934 -4935 -4936 -4937 -4938 -4939 -494 -4940 -4941 -4942 -4943 -4944 -4945 -4946 -4947 -4948 -4949 -495 -4950 -4951 -4952 -4953 -4954 -4955 -4956 -4957 -4958 -4959 -496 -4960 -4961 -4962 -4963 -4964 -4965 -4966 -4967 -4968 -4969 -497 -4970 -4971 -4972 -4973 -4974 -4975 -4976 -4977 -4978 -4979 -498 -4980 -4981 -4982 -4983 -4984 -4985 -4986 -4987 -4988 -4989 -499 -4990 -4991 -4992 -4993 -4994 -4995 -4996 -4997 -4998 -4999 -5 -50 -500 -5000 -5001 -5002 -5003 -5004 -5005 -5006 -5007 -5008 -5009 -501 -5010 -5011 -5012 -5013 -5014 -5015 -5016 -5017 -5018 -5019 -502 -5020 -5021 -5022 -5023 -5024 -5025 -5026 -5027 -5028 -5029 -503 -5030 -5031 -5032 -5033 -5034 -5035 -5036 -5037 -5038 -5039 -504 -5040 -5041 -5042 -5043 -5044 -5045 -5046 -5047 -5048 -5049 -505 -5050 -5051 -5052 -5053 -5054 -5055 -5056 -5057 -5058 -5059 -506 -5060 -5061 -5062 -5063 -5064 -5065 -5066 -5067 -5068 -5069 -507 -5070 -5071 -5072 -5073 -5074 -5075 -5076 -5077 -5078 -5079 -508 -5080 -5081 -5082 -5083 -5084 -5085 -5086 -5087 -5088 -5089 -509 -5090 -5091 -5092 -5093 -5094 -5095 -5096 -5097 -5098 -5099 -51 -510 -5100 -5101 -5102 -5103 -5104 -5105 -5106 -5107 -5108 -5109 -511 -5110 -5111 -5112 -5113 -5114 -5115 -5116 -5117 -5118 -5119 -512 -5120 -5121 -5122 -5123 -5124 -5125 -5126 -5127 -5128 -5129 -513 -5130 -5131 -5132 -5133 -5134 -5135 -5136 -5137 -5138 -5139 -514 -5140 -5141 -5142 -5143 -5144 -5145 -5146 -5147 -5148 -5149 -515 -5150 -5151 -5152 -5153 -5154 -5155 -5156 -5157 -5158 -5159 -516 -5160 -5161 -5162 -5163 -5164 -5165 -5166 -5167 -5168 -5169 -517 -5170 -5171 -5172 -5173 -5174 -5175 -5176 -5177 -5178 -5179 -518 -5180 -5181 -5182 -5183 -5184 -5185 -5186 -5187 -5188 -5189 -519 -5190 -5191 -5192 -5193 -5194 -5195 -5196 -5197 -5198 -5199 -52 -520 -5200 -5201 -5202 -5203 -5204 -5205 -5206 -5207 -5208 -5209 -521 -5210 -5211 -5212 -5213 -5214 -5215 -5216 -5217 -5218 -5219 -522 -5220 -5221 -5222 -5223 -5224 -5225 -5226 -5227 -5228 -5229 -523 -5230 -5231 -5232 -5233 -5234 -5235 -5236 -5237 -5238 -5239 -524 -5240 -5241 -5242 -5243 -5244 -5245 -5246 -5247 -5248 -5249 -525 -5250 -5251 -5252 -5253 -5254 -5255 -5256 -5257 -5258 -5259 -526 -5260 -5261 -5262 -5263 -5264 -5265 -5266 -5267 -5268 -5269 -527 -5270 -5271 -5272 -5273 -5274 -5275 -5276 -5277 -5278 -5279 -528 -5280 -5281 -5282 -5283 -5284 -5285 -5286 -5287 -5288 -5289 -529 -5290 -5291 -5292 -5293 -5294 -5295 -5296 -5297 -5298 -5299 -53 -530 -5300 -5301 -5302 -5303 -5304 -5305 -5306 -5307 -5308 -5309 -531 -5310 -5311 -5312 -5313 -5314 -5315 -5316 -5317 -5318 -5319 -532 -5320 -5321 -5322 -5323 -5324 -5325 -5326 -5327 -5328 -5329 -533 -5330 -5331 -5332 -5333 -5334 -5335 -5336 -5337 -5338 -5339 -534 -5340 -5341 -5342 -5343 -5344 -5345 -5346 -5347 -5348 -5349 -535 -5350 -5351 -5352 -5353 -5354 -5355 -5356 -5357 -5358 -5359 -536 -5360 -5361 -5362 -5363 -5364 -5365 -5366 -5367 -5368 -5369 -537 -5370 -5371 -5372 -5373 -5374 -5375 -5376 -5377 -5378 -5379 -538 -5380 -5381 -5382 -5383 -5384 -5385 -5386 -5387 -5388 -5389 -539 -5390 -5391 -5392 -5393 -5394 -5395 -5396 -5397 -5398 -5399 -54 -540 -5400 -5401 -5402 -5403 -5404 -5405 -5406 -5407 -5408 -5409 -541 -5410 -5411 -5412 -5413 -5414 -5415 -5416 -5417 -5418 -5419 -542 -5420 -5421 -5422 -5423 -5424 -5425 -5426 -5427 -5428 -5429 -543 -5430 -5431 -5432 -5433 -5434 -5435 -5436 -5437 -5438 -5439 -544 -5440 -5441 -5442 -5443 -5444 -5445 -5446 -5447 -5448 -5449 -545 -5450 -5451 -5452 -5453 -5454 -5455 -5456 -5457 -5458 -5459 -546 -5460 -5461 -5462 -5463 -5464 -5465 -5466 -5467 -5468 -5469 -547 -5470 -5471 -5472 -5473 -5474 -5475 -5476 -5477 -5478 -5479 -548 -5480 -5481 -5482 -5483 -5484 -5485 -5486 -5487 -5488 -5489 -549 -5490 -5491 -5492 -5493 -5494 -5495 -5496 -5497 -5498 -5499 -55 -550 -5500 -5501 -5502 -5503 -5504 -5505 -5506 -5507 -5508 -5509 -551 -5510 -5511 -5512 -5513 -5514 -5515 -5516 -5517 -5518 -5519 -552 -5520 -5521 -5522 -5523 -5524 -5525 -5526 -5527 -5528 -5529 -553 -5530 -5531 -5532 -5533 -5534 -5535 -5536 -5537 -5538 -5539 -554 -5540 -5541 -5542 -5543 -5544 -5545 -5546 -5547 -5548 -5549 -555 -5550 -5551 -5552 -5553 -5554 -5555 -5556 -5557 -5558 -5559 -556 -5560 -5561 -5562 -5563 -5564 -5565 -5566 -5567 -5568 -5569 -557 -5570 -5571 -5572 -5573 -5574 -5575 -5576 -5577 -5578 -5579 -558 -5580 -5581 -5582 -5583 -5584 -5585 -5586 -5587 -5588 -5589 -559 -5590 -5591 -5592 -5593 -5594 -5595 -5596 -5597 -5598 -5599 -56 -560 -5600 -5601 -5602 -5603 -5604 -5605 -5606 -5607 -5608 -5609 -561 -5610 -5611 -5612 -5613 -5614 -5615 -5616 -5617 -5618 -5619 -562 -5620 -5621 -5622 -5623 -5624 -5625 -5626 -5627 -5628 -5629 -563 -5630 -5631 -5632 -5633 -5634 -5635 -5636 -5637 -5638 -5639 -564 -5640 -5641 -5642 -5643 -5644 -5645 -5646 -5647 -5648 -5649 -565 -5650 -5651 -5652 -5653 -5654 -5655 -5656 -5657 -5658 -5659 -566 -5660 -5661 -5662 -5663 -5664 -5665 -5666 -5667 -5668 -5669 -567 -5670 -5671 -5672 -5673 -5674 -5675 -5676 -5677 -5678 -5679 -568 -5680 -5681 -5682 -5683 -5684 -5685 -5686 -5687 -5688 -5689 -569 -5690 -5691 -5692 -5693 -5694 -5695 -5696 -5697 -5698 -5699 -57 -570 -5700 -5701 -5702 -5703 -5704 -5705 -5706 -5707 -5708 -5709 -571 -5710 -5711 -5712 -5713 -5714 -5715 -5716 -5717 -5718 -5719 -572 -5720 -5721 -5722 -5723 -5724 -5725 -5726 -5727 -5728 -5729 -573 -5730 -5731 -5732 -5733 -5734 -5735 -5736 -5737 -5738 -5739 -574 -5740 -5741 -5742 -5743 -5744 -5745 -5746 -5747 -5748 -5749 -575 -5750 -5751 -5752 -5753 -5754 -5755 -5756 -5757 -5758 -5759 -576 -5760 -5761 -5762 -5763 -5764 -5765 -5766 -5767 -5768 -5769 -577 -5770 -5771 -5772 -5773 -5774 -5775 -5776 -5777 -5778 -5779 -578 -5780 -5781 -5782 -5783 -5784 -5785 -5786 -5787 -5788 -5789 -579 -5790 -5791 -5792 -5793 -5794 -5795 -5796 -5797 -5798 -5799 -58 -580 -5800 -5801 -5802 -5803 -5804 -5805 -5806 -5807 -5808 -5809 -581 -5810 -5811 -5812 -5813 -5814 -5815 -5816 -5817 -5818 -5819 -582 -5820 -5821 -5822 -5823 -5824 -5825 -5826 -5827 -5828 -5829 -583 -5830 -5831 -5832 -5833 -5834 -5835 -5836 -5837 -5838 -5839 -584 -5840 -5841 -5842 -5843 -5844 -5845 -5846 -5847 -5848 -5849 -585 -5850 -5851 -5852 -5853 -5854 -5855 -5856 -5857 -5858 -5859 -586 -5860 -5861 -5862 -5863 -5864 -5865 -5866 -5867 -5868 -5869 -587 -5870 -5871 -5872 -5873 -5874 -5875 -5876 -5877 -5878 -5879 -588 -5880 -5881 -5882 -5883 -5884 -5885 -5886 -5887 -5888 -5889 -589 -5890 -5891 -5892 -5893 -5894 -5895 -5896 -5897 -5898 -5899 -59 -590 -5900 -5901 -5902 -5903 -5904 -5905 -5906 -5907 -5908 -5909 -591 -5910 -5911 -5912 -5913 -5914 -5915 -5916 -5917 -5918 -5919 -592 -5920 -5921 -5922 -5923 -5924 -5925 -5926 -5927 -5928 -5929 -593 -5930 -5931 -5932 -5933 -5934 -5935 -5936 -5937 -5938 -5939 -594 -5940 -5941 -5942 -5943 -5944 -5945 -5946 -5947 -5948 -5949 -595 -5950 -5951 -5952 -5953 -5954 -5955 -5956 -5957 -5958 -5959 -596 -5960 -5961 -5962 -5963 -5964 -5965 -5966 -5967 -5968 -5969 -597 -5970 -5971 -5972 -5973 -5974 -5975 -5976 -5977 -5978 -5979 -598 -5980 -5981 -5982 -5983 -5984 -5985 -5986 -5987 -5988 -5989 -599 -5990 -5991 -5992 -5993 -5994 -5995 -5996 -5997 -5998 -5999 -6 -60 -600 -6000 -6001 -6002 -6003 -6004 -6005 -6006 -6007 -6008 -6009 -601 -6010 -6011 -6012 -6013 -6014 -6015 -6016 -6017 -6018 -6019 -602 -6020 -6021 -6022 -6023 -6024 -6025 -6026 -6027 -6028 -6029 -603 -6030 -6031 -6032 -6033 -6034 -6035 -6036 -6037 -6038 -6039 -604 -6040 -6041 -6042 -6043 -6044 -6045 -6046 -6047 -6048 -6049 -605 -6050 -6051 -6052 -6053 -6054 -6055 -6056 -6057 -6058 -6059 -606 -6060 -6061 -6062 -6063 -6064 -6065 -6066 -6067 -6068 -6069 -607 -6070 -6071 -6072 -6073 -6074 -6075 -6076 -6077 -6078 -6079 -608 -6080 -6081 -6082 -6083 -6084 -6085 -6086 -6087 -6088 -6089 -609 -6090 -6091 -6092 -6093 -6094 -6095 -6096 -6097 -6098 -6099 -61 -610 -6100 -6101 -6102 -6103 -6104 -6105 -6106 -6107 -6108 -6109 -611 -6110 -6111 -6112 -6113 -6114 -6115 -6116 -6117 -6118 -6119 -612 -6120 -6121 -6122 -6123 -6124 -6125 -6126 -6127 -6128 -6129 -613 -6130 -6131 -6132 -6133 -6134 -6135 -6136 -6137 -6138 -6139 -614 -6140 -6141 -6142 -6143 -6144 -6145 -6146 -6147 -6148 -6149 -615 -6150 -6151 -6152 -6153 -6154 -6155 -6156 -6157 -6158 -6159 -616 -6160 -6161 -6162 -6163 -6164 -6165 -6166 -6167 -6168 -6169 -617 -6170 -6171 -6172 -6173 -6174 -6175 -6176 -6177 -6178 -6179 -618 -6180 -6181 -6182 -6183 -6184 -6185 -6186 -6187 -6188 -6189 -619 -6190 -6191 -6192 -6193 -6194 -6195 -6196 -6197 -6198 -6199 -62 -620 -6200 -6201 -6202 -6203 -6204 -6205 -6206 -6207 -6208 -6209 -621 -6210 -6211 -6212 -6213 -6214 -6215 -6216 -6217 -6218 -6219 -622 -6220 -6221 -6222 -6223 -6224 -6225 -6226 -6227 -6228 -6229 -623 -6230 -6231 -6232 -6233 -6234 -6235 -6236 -6237 -6238 -6239 -624 -6240 -6241 -6242 -6243 -6244 -6245 -6246 -6247 -6248 -6249 -625 -6250 -6251 -6252 -6253 -6254 -6255 -6256 -6257 -6258 -6259 -626 -6260 -6261 -6262 -6263 -6264 -6265 -6266 -6267 -6268 -6269 -627 -6270 -6271 -6272 -6273 -6274 -6275 -6276 -6277 -6278 -6279 -628 -6280 -6281 -6282 -6283 -6284 -6285 -6286 -6287 -6288 -6289 -629 -6290 -6291 -6292 -6293 -6294 -6295 -6296 -6297 -6298 -6299 -63 -630 -6300 -6301 -6302 -6303 -6304 -6305 -6306 -6307 -6308 -6309 -631 -6310 -6311 -6312 -6313 -6314 -6315 -6316 -6317 -6318 -6319 -632 -6320 -6321 -6322 -6323 -6324 -6325 -6326 -6327 -6328 -6329 -633 -6330 -6331 -6332 -6333 -6334 -6335 -6336 -6337 -6338 -6339 -634 -6340 -6341 -6342 -6343 -6344 -6345 -6346 -6347 -6348 -6349 -635 -6350 -6351 -6352 -6353 -6354 -6355 -6356 -6357 -6358 -6359 -636 -6360 -6361 -6362 -6363 -6364 -6365 -6366 -6367 -6368 -6369 -637 -6370 -6371 -6372 -6373 -6374 -6375 -6376 -6377 -6378 -6379 -638 -6380 -6381 -6382 -6383 -6384 -6385 -6386 -6387 -6388 -6389 -639 -6390 -6391 -6392 -6393 -6394 -6395 -6396 -6397 -6398 -6399 -64 -640 -6400 -6401 -6402 -6403 -6404 -6405 -6406 -6407 -6408 -6409 -641 -6410 -6411 -6412 -6413 -6414 -6415 -6416 -6417 -6418 -6419 -642 -6420 -6421 -6422 -6423 -6424 -6425 -6426 -6427 -6428 -6429 -643 -6430 -6431 -6432 -6433 -6434 -6435 -6436 -6437 -6438 -6439 -644 -6440 -6441 -6442 -6443 -6444 -6445 -6446 -6447 -6448 -6449 -645 -6450 -6451 -6452 -6453 -6454 -6455 -6456 -6457 -6458 -6459 -646 -6460 -6461 -6462 -6463 -6464 -6465 -6466 -6467 -6468 -6469 -647 -6470 -6471 -6472 -6473 -6474 -6475 -6476 -6477 -6478 -6479 -648 -6480 -6481 -6482 -6483 -6484 -6485 -6486 -6487 -6488 -6489 -649 -6490 -6491 -6492 -6493 -6494 -6495 -6496 -6497 -6498 -6499 -65 -650 -6500 -6501 -6502 -6503 -6504 -6505 -6506 -6507 -6508 -6509 -651 -6510 -6511 -6512 -6513 -6514 -6515 -6516 -6517 -6518 -6519 -652 -6520 -6521 -6522 -6523 -6524 -6525 -6526 -6527 -6528 -6529 -653 -6530 -6531 -6532 -6533 -6534 -6535 -6536 -6537 -6538 -6539 -654 -6540 -6541 -6542 -6543 -6544 -6545 -6546 -6547 -6548 -6549 -655 -6550 -6551 -6552 -6553 -6554 -6555 -6556 -6557 -6558 -6559 -656 -6560 -6561 -6562 -6563 -6564 -6565 -6566 -6567 -6568 -6569 -657 -6570 -6571 -6572 -6573 -6574 -6575 -6576 -6577 -6578 -6579 -658 -6580 -6581 -6582 -6583 -6584 -6585 -6586 -6587 -6588 -6589 -659 -6590 -6591 -6592 -6593 -6594 -6595 -6596 -6597 -6598 -6599 -66 -660 -6600 -6601 -6602 -6603 -6604 -6605 -6606 -6607 -6608 -6609 -661 -6610 -6611 -6612 -6613 -6614 -6615 -6616 -6617 -6618 -6619 -662 -6620 -6621 -6622 -6623 -6624 -6625 -6626 -6627 -6628 -6629 -663 -6630 -6631 -6632 -6633 -6634 -6635 -6636 -6637 -6638 -6639 -664 -6640 -6641 -6642 -6643 -6644 -6645 -6646 -6647 -6648 -6649 -665 -6650 -6651 -6652 -6653 -6654 -6655 -6656 -6657 -6658 -6659 -666 -6660 -6661 -6662 -6663 -6664 -6665 -6666 -6667 -6668 -6669 -667 -6670 -6671 -6672 -6673 -6674 -6675 -6676 -6677 -6678 -6679 -668 -6680 -6681 -6682 -6683 -6684 -6685 -6686 -6687 -6688 -6689 -669 -6690 -6691 -6692 -6693 -6694 -6695 -6696 -6697 -6698 -6699 -67 -670 -6700 -6701 -6702 -6703 -6704 -6705 -6706 -6707 -6708 -6709 -671 -6710 -6711 -6712 -6713 -6714 -6715 -6716 -6717 -6718 -6719 -672 -6720 -6721 -6722 -6723 -6724 -6725 -6726 -6727 -6728 -6729 -673 -6730 -6731 -6732 -6733 -6734 -6735 -6736 -6737 -6738 -6739 -674 -6740 -6741 -6742 -6743 -6744 -6745 -6746 -6747 -6748 -6749 -675 -6750 -6751 -6752 -6753 -6754 -6755 -6756 -6757 -6758 -6759 -676 -6760 -6761 -6762 -6763 -6764 -6765 -6766 -6767 -6768 -6769 -677 -6770 -6771 -6772 -6773 -6774 -6775 -6776 -6777 -6778 -6779 -678 -6780 -6781 -6782 -6783 -6784 -6785 -6786 -6787 -6788 -6789 -679 -6790 -6791 -6792 -6793 -6794 -6795 -6796 -6797 -6798 -6799 -68 -680 -6800 -6801 -6802 -6803 -6804 -6805 -6806 -6807 -6808 -6809 -681 -6810 -6811 -6812 -6813 -6814 -6815 -6816 -6817 -6818 -6819 -682 -6820 -6821 -6822 -6823 -6824 -6825 -6826 -6827 -6828 -6829 -683 -6830 -6831 -6832 -6833 -6834 -6835 -6836 -6837 -6838 -6839 -684 -6840 -6841 -6842 -6843 -6844 -6845 -6846 -6847 -6848 -6849 -685 -6850 -6851 -6852 -6853 -6854 -6855 -6856 -6857 -6858 -6859 -686 -6860 -6861 -6862 -6863 -6864 -6865 -6866 -6867 -6868 -6869 -687 -6870 -6871 -6872 -6873 -6874 -6875 -6876 -6877 -6878 -6879 -688 -6880 -6881 -6882 -6883 -6884 -6885 -6886 -6887 -6888 -6889 -689 -6890 -6891 -6892 -6893 -6894 -6895 -6896 -6897 -6898 -6899 -69 -690 -6900 -6901 -6902 -6903 -6904 -6905 -6906 -6907 -6908 -6909 -691 -6910 -6911 -6912 -6913 -6914 -6915 -6916 -6917 -6918 -6919 -692 -6920 -6921 -6922 -6923 -6924 -6925 -6926 -6927 -6928 -6929 -693 -6930 -6931 -6932 -6933 -6934 -6935 -6936 -6937 -6938 -6939 -694 -6940 -6941 -6942 -6943 -6944 -6945 -6946 -6947 -6948 -6949 -695 -6950 -6951 -6952 -6953 -6954 -6955 -6956 -6957 -6958 -6959 -696 -6960 -6961 -6962 -6963 -6964 -6965 -6966 -6967 -6968 -6969 -697 -6970 -6971 -6972 -6973 -6974 -6975 -6976 -6977 -6978 -6979 -698 -6980 -6981 -6982 -6983 -6984 -6985 -6986 -6987 -6988 -6989 -699 -6990 -6991 -6992 -6993 -6994 -6995 -6996 -6997 -6998 -6999 -7 -70 -700 -7000 -7001 -7002 -7003 -7004 -7005 -7006 -7007 -7008 -7009 -701 -7010 -7011 -7012 -7013 -7014 -7015 -7016 -7017 -7018 -7019 -702 -7020 -7021 -7022 -7023 -7024 -7025 -7026 -7027 -7028 -7029 -703 -7030 -7031 -7032 -7033 -7034 -7035 -7036 -7037 -7038 -7039 -704 -7040 -7041 -7042 -7043 -7044 -7045 -7046 -7047 -7048 -7049 -705 -7050 -7051 -7052 -7053 -7054 -7055 -7056 -7057 -7058 -7059 -706 -7060 -7061 -7062 -7063 -7064 -7065 -7066 -7067 -7068 -7069 -707 -7070 -7071 -7072 -7073 -7074 -7075 -7076 -7077 -7078 -7079 -708 -7080 -7081 -7082 -7083 -7084 -7085 -7086 -7087 -7088 -7089 -709 -7090 -7091 -7092 -7093 -7094 -7095 -7096 -7097 -7098 -7099 -71 -710 -7100 -7101 -7102 -7103 -7104 -7105 -7106 -7107 -7108 -7109 -711 -7110 -7111 -7112 -7113 -7114 -7115 -7116 -7117 -7118 -7119 -712 -7120 -7121 -7122 -7123 -7124 -7125 -7126 -7127 -7128 -7129 -713 -7130 -7131 -7132 -7133 -7134 -7135 -7136 -7137 -7138 -7139 -714 -7140 -7141 -7142 -7143 -7144 -7145 -7146 -7147 -7148 -7149 -715 -7150 -7151 -7152 -7153 -7154 -7155 -7156 -7157 -7158 -7159 -716 -7160 -7161 -7162 -7163 -7164 -7165 -7166 -7167 -7168 -7169 -717 -7170 -7171 -7172 -7173 -7174 -7175 -7176 -7177 -7178 -7179 -718 -7180 -7181 -7182 -7183 -7184 -7185 -7186 -7187 -7188 -7189 -719 -7190 -7191 -7192 -7193 -7194 -7195 -7196 -7197 -7198 -7199 -72 -720 -7200 -7201 -7202 -7203 -7204 -7205 -7206 -7207 -7208 -7209 -721 -7210 -7211 -7212 -7213 -7214 -7215 -7216 -7217 -7218 -7219 -722 -7220 -7221 -7222 -7223 -7224 -7225 -7226 -7227 -7228 -7229 -723 -7230 -7231 -7232 -7233 -7234 -7235 -7236 -7237 -7238 -7239 -724 -7240 -7241 -7242 -7243 -7244 -7245 -7246 -7247 -7248 -7249 -725 -7250 -7251 -7252 -7253 -7254 -7255 -7256 -7257 -7258 -7259 -726 -7260 -7261 -7262 -7263 -7264 -7265 -7266 -7267 -7268 -7269 -727 -7270 -7271 -7272 -7273 -7274 -7275 -7276 -7277 -7278 -7279 -728 -7280 -7281 -7282 -7283 -7284 -7285 -7286 -7287 -7288 -7289 -729 -7290 -7291 -7292 -7293 -7294 -7295 -7296 -7297 -7298 -7299 -73 -730 -7300 -7301 -7302 -7303 -7304 -7305 -7306 -7307 -7308 -7309 -731 -7310 -7311 -7312 -7313 -7314 -7315 -7316 -7317 -7318 -7319 -732 -7320 -7321 -7322 -7323 -7324 -7325 -7326 -7327 -7328 -7329 -733 -7330 -7331 -7332 -7333 -7334 -7335 -7336 -7337 -7338 -7339 -734 -7340 -7341 -7342 -7343 -7344 -7345 -7346 -7347 -7348 -7349 -735 -7350 -7351 -7352 -7353 -7354 -7355 -7356 -7357 -7358 -7359 -736 -7360 -7361 -7362 -7363 -7364 -7365 -7366 -7367 -7368 -7369 -737 -7370 -7371 -7372 -7373 -7374 -7375 -7376 -7377 -7378 -7379 -738 -7380 -7381 -7382 -7383 -7384 -7385 -7386 -7387 -7388 -7389 -739 -7390 -7391 -7392 -7393 -7394 -7395 -7396 -7397 -7398 -7399 -74 -740 -7400 -7401 -7402 -7403 -7404 -7405 -7406 -7407 -7408 -7409 -741 -7410 -7411 -7412 -7413 -7414 -7415 -7416 -7417 -7418 -7419 -742 -7420 -7421 -7422 -7423 -7424 -7425 -7426 -7427 -7428 -7429 -743 -7430 -7431 -7432 -7433 -7434 -7435 -7436 -7437 -7438 -7439 -744 -7440 -7441 -7442 -7443 -7444 -7445 -7446 -7447 -7448 -7449 -745 -7450 -7451 -7452 -7453 -7454 -7455 -7456 -7457 -7458 -7459 -746 -7460 -7461 -7462 -7463 -7464 -7465 -7466 -7467 -7468 -7469 -747 -7470 -7471 -7472 -7473 -7474 -7475 -7476 -7477 -7478 -7479 -748 -7480 -7481 -7482 -7483 -7484 -7485 -7486 -7487 -7488 -7489 -749 -7490 -7491 -7492 -7493 -7494 -7495 -7496 -7497 -7498 -7499 -75 -750 -7500 -7501 -7502 -7503 -7504 -7505 -7506 -7507 -7508 -7509 -751 -7510 -7511 -7512 -7513 -7514 -7515 -7516 -7517 -7518 -7519 -752 -7520 -7521 -7522 -7523 -7524 -7525 -7526 -7527 -7528 -7529 -753 -7530 -7531 -7532 -7533 -7534 -7535 -7536 -7537 -7538 -7539 -754 -7540 -7541 -7542 -7543 -7544 -7545 -7546 -7547 -7548 -7549 -755 -7550 -7551 -7552 -7553 -7554 -7555 -7556 -7557 -7558 -7559 -756 -7560 -7561 -7562 -7563 -7564 -7565 -7566 -7567 -7568 -7569 -757 -7570 -7571 -7572 -7573 -7574 -7575 -7576 -7577 -7578 -7579 -758 -7580 -7581 -7582 -7583 -7584 -7585 -7586 -7587 -7588 -7589 -759 -7590 -7591 -7592 -7593 -7594 -7595 -7596 -7597 -7598 -7599 -76 -760 -7600 -7601 -7602 -7603 -7604 -7605 -7606 -7607 -7608 -7609 -761 -7610 -7611 -7612 -7613 -7614 -7615 -7616 -7617 -7618 -7619 -762 -7620 -7621 -7622 -7623 -7624 -7625 -7626 -7627 -7628 -7629 -763 -7630 -7631 -7632 -7633 -7634 -7635 -7636 -7637 -7638 -7639 -764 -7640 -7641 -7642 -7643 -7644 -7645 -7646 -7647 -7648 -7649 -765 -7650 -7651 -7652 -7653 -7654 -7655 -7656 -7657 -7658 -7659 -766 -7660 -7661 -7662 -7663 -7664 -7665 -7666 -7667 -7668 -7669 -767 -7670 -7671 -7672 -7673 -7674 -7675 -7676 -7677 -7678 -7679 -768 -7680 -7681 -7682 -7683 -7684 -7685 -7686 -7687 -7688 -7689 -769 -7690 -7691 -7692 -7693 -7694 -7695 -7696 -7697 -7698 -7699 -77 -770 -7700 -7701 -7702 -7703 -7704 -7705 -7706 -7707 -7708 -7709 -771 -7710 -7711 -7712 -7713 -7714 -7715 -7716 -7717 -7718 -7719 -772 -7720 -7721 -7722 -7723 -7724 -7725 -7726 -7727 -7728 -7729 -773 -7730 -7731 -7732 -7733 -7734 -7735 -7736 -7737 -7738 -7739 -774 -7740 -7741 -7742 -7743 -7744 -7745 -7746 -7747 -7748 -7749 -775 -7750 -7751 -7752 -7753 -7754 -7755 -7756 -7757 -7758 -7759 -776 -7760 -7761 -7762 -7763 -7764 -7765 -7766 -7767 -7768 -7769 -777 -7770 -7771 -7772 -7773 -7774 -7775 -7776 -7777 -7778 -7779 -778 -7780 -7781 -7782 -7783 -7784 -7785 -7786 -7787 -7788 -7789 -779 -7790 -7791 -7792 -7793 -7794 -7795 -7796 -7797 -7798 -7799 -78 -780 -7800 -7801 -7802 -7803 -7804 -7805 -7806 -7807 -7808 -7809 -781 -7810 -7811 -7812 -7813 -7814 -7815 -7816 -7817 -7818 -7819 -782 -7820 -7821 -7822 -7823 -7824 -7825 -7826 -7827 -7828 -7829 -783 -7830 -7831 -7832 -7833 -7834 -7835 -7836 -7837 -7838 -7839 -784 -7840 -7841 -7842 -7843 -7844 -7845 -7846 -7847 -7848 -7849 -785 -7850 -7851 -7852 -7853 -7854 -7855 -7856 -7857 -7858 -7859 -786 -7860 -7861 -7862 -7863 -7864 -7865 -7866 -7867 -7868 -7869 -787 -7870 -7871 -7872 -7873 -7874 -7875 -7876 -7877 -7878 -7879 -788 -7880 -7881 -7882 -7883 -7884 -7885 -7886 -7887 -7888 -7889 -789 -7890 -7891 -7892 -7893 -7894 -7895 -7896 -7897 -7898 -7899 -79 -790 -7900 -7901 -7902 -7903 -7904 -7905 -7906 -7907 -7908 -7909 -791 -7910 -7911 -7912 -7913 -7914 -7915 -7916 -7917 -7918 -7919 -792 -7920 -7921 -7922 -7923 -7924 -7925 -7926 -7927 -7928 -7929 -793 -7930 -7931 -7932 -7933 -7934 -7935 -7936 -7937 -7938 -7939 -794 -7940 -7941 -7942 -7943 -7944 -7945 -7946 -7947 -7948 -7949 -795 -7950 -7951 -7952 -7953 -7954 -7955 -7956 -7957 -7958 -7959 -796 -7960 -7961 -7962 -7963 -7964 -7965 -7966 -7967 -7968 -7969 -797 -7970 -7971 -7972 -7973 -7974 -7975 -7976 -7977 -7978 -7979 -798 -7980 -7981 -7982 -7983 -7984 -7985 -7986 -7987 -7988 -7989 -799 -7990 -7991 -7992 -7993 -7994 -7995 -7996 -7997 -7998 -7999 -8 -80 -800 -8000 -8001 -8002 -8003 -8004 -8005 -8006 -8007 -8008 -8009 -801 -8010 -8011 -8012 -8013 -8014 -8015 -8016 -8017 -8018 -8019 -802 -8020 -8021 -8022 -8023 -8024 -8025 -8026 -8027 -8028 -8029 -803 -8030 -8031 -8032 -8033 -8034 -8035 -8036 -8037 -8038 -8039 -804 -8040 -8041 -8042 -8043 -8044 -8045 -8046 -8047 -8048 -8049 -805 -8050 -8051 -8052 -8053 -8054 -8055 -8056 -8057 -8058 -8059 -806 -8060 -8061 -8062 -8063 -8064 -8065 -8066 -8067 -8068 -8069 -807 -8070 -8071 -8072 -8073 -8074 -8075 -8076 -8077 -8078 -8079 -808 -8080 -8081 -8082 -8083 -8084 -8085 -8086 -8087 -8088 -8089 -809 -8090 -8091 -8092 -8093 -8094 -8095 -8096 -8097 -8098 -8099 -81 -810 -8100 -8101 -8102 -8103 -8104 -8105 -8106 -8107 -8108 -8109 -811 -8110 -8111 -8112 -8113 -8114 -8115 -8116 -8117 -8118 -8119 -812 -8120 -8121 -8122 -8123 -8124 -8125 -8126 -8127 -8128 -8129 -813 -8130 -8131 -8132 -8133 -8134 -8135 -8136 -8137 -8138 -8139 -814 -8140 -8141 -8142 -8143 -8144 -8145 -8146 -8147 -8148 -8149 -815 -8150 -8151 -8152 -8153 -8154 -8155 -8156 -8157 -8158 -8159 -816 -8160 -8161 -8162 -8163 -8164 -8165 -8166 -8167 -8168 -8169 -817 -8170 -8171 -8172 -8173 -8174 -8175 -8176 -8177 -8178 -8179 -818 -8180 -8181 -8182 -8183 -8184 -8185 -8186 -8187 -8188 -8189 -819 -8190 -8191 -8192 -8193 -8194 -8195 -8196 -8197 -8198 -8199 -82 -820 -8200 -8201 -8202 -8203 -8204 -8205 -8206 -8207 -8208 -8209 -821 -8210 -8211 -8212 -8213 -8214 -8215 -8216 -8217 -8218 -8219 -822 -8220 -8221 -8222 -8223 -8224 -8225 -8226 -8227 -8228 -8229 -823 -8230 -8231 -8232 -8233 -8234 -8235 -8236 -8237 -8238 -8239 -824 -8240 -8241 -8242 -8243 -8244 -8245 -8246 -8247 -8248 -8249 -825 -8250 -8251 -8252 -8253 -8254 -8255 -8256 -8257 -8258 -8259 -826 -8260 -8261 -8262 -8263 -8264 -8265 -8266 -8267 -8268 -8269 -827 -8270 -8271 -8272 -8273 -8274 -8275 -8276 -8277 -8278 -8279 -828 -8280 -8281 -8282 -8283 -8284 -8285 -8286 -8287 -8288 -8289 -829 -8290 -8291 -8292 -8293 -8294 -8295 -8296 -8297 -8298 -8299 -83 -830 -8300 -8301 -8302 -8303 -8304 -8305 -8306 -8307 -8308 -8309 -831 -8310 -8311 -8312 -8313 -8314 -8315 -8316 -8317 -8318 -8319 -832 -8320 -8321 -8322 -8323 -8324 -8325 -8326 -8327 -8328 -8329 -833 -8330 -8331 -8332 -8333 -8334 -8335 -8336 -8337 -8338 -8339 -834 -8340 -8341 -8342 -8343 -8344 -8345 -8346 -8347 -8348 -8349 -835 -8350 -8351 -8352 -8353 -8354 -8355 -8356 -8357 -8358 -8359 -836 -8360 -8361 -8362 -8363 -8364 -8365 -8366 -8367 -8368 -8369 -837 -8370 -8371 -8372 -8373 -8374 -8375 -8376 -8377 -8378 -8379 -838 -8380 -8381 -8382 -8383 -8384 -8385 -8386 -8387 -8388 -8389 -839 -8390 -8391 -8392 -8393 -8394 -8395 -8396 -8397 -8398 -8399 -84 -840 -8400 -8401 -8402 -8403 -8404 -8405 -8406 -8407 -8408 -8409 -841 -8410 -8411 -8412 -8413 -8414 -8415 -8416 -8417 -8418 -8419 -842 -8420 -8421 -8422 -8423 -8424 -8425 -8426 -8427 -8428 -8429 -843 -8430 -8431 -8432 -8433 -8434 -8435 -8436 -8437 -8438 -8439 -844 -8440 -8441 -8442 -8443 -8444 -8445 -8446 -8447 -8448 -8449 -845 -8450 -8451 -8452 -8453 -8454 -8455 -8456 -8457 -8458 -8459 -846 -8460 -8461 -8462 -8463 -8464 -8465 -8466 -8467 -8468 -8469 -847 -8470 -8471 -8472 -8473 -8474 -8475 -8476 -8477 -8478 -8479 -848 -8480 -8481 -8482 -8483 -8484 -8485 -8486 -8487 -8488 -8489 -849 -8490 -8491 -8492 -8493 -8494 -8495 -8496 -8497 -8498 -8499 -85 -850 -8500 -8501 -8502 -8503 -8504 -8505 -8506 -8507 -8508 -8509 -851 -8510 -8511 -8512 -8513 -8514 -8515 -8516 -8517 -8518 -8519 -852 -8520 -8521 -8522 -8523 -8524 -8525 -8526 -8527 -8528 -8529 -853 -8530 -8531 -8532 -8533 -8534 -8535 -8536 -8537 -8538 -8539 -854 -8540 -8541 -8542 -8543 -8544 -8545 -8546 -8547 -8548 -8549 -855 -8550 -8551 -8552 -8553 -8554 -8555 -8556 -8557 -8558 -8559 -856 -8560 -8561 -8562 -8563 -8564 -8565 -8566 -8567 -8568 -8569 -857 -8570 -8571 -8572 -8573 -8574 -8575 -8576 -8577 -8578 -8579 -858 -8580 -8581 -8582 -8583 -8584 -8585 -8586 -8587 -8588 -8589 -859 -8590 -8591 -8592 -8593 -8594 -8595 -8596 -8597 -8598 -8599 -86 -860 -8600 -8601 -8602 -8603 -8604 -8605 -8606 -8607 -8608 -8609 -861 -8610 -8611 -8612 -8613 -8614 -8615 -8616 -8617 -8618 -8619 -862 -8620 -8621 -8622 -8623 -8624 -8625 -8626 -8627 -8628 -8629 -863 -8630 -8631 -8632 -8633 -8634 -8635 -8636 -8637 -8638 -8639 -864 -8640 -8641 -8642 -8643 -8644 -8645 -8646 -8647 -8648 -8649 -865 -8650 -8651 -8652 -8653 -8654 -8655 -8656 -8657 -8658 -8659 -866 -8660 -8661 -8662 -8663 -8664 -8665 -8666 -8667 -8668 -8669 -867 -8670 -8671 -8672 -8673 -8674 -8675 -8676 -8677 -8678 -8679 -868 -8680 -8681 -8682 -8683 -8684 -8685 -8686 -8687 -8688 -8689 -869 -8690 -8691 -8692 -8693 -8694 -8695 -8696 -8697 -8698 -8699 -87 -870 -8700 -8701 -8702 -8703 -8704 -8705 -8706 -8707 -8708 -8709 -871 -8710 -8711 -8712 -8713 -8714 -8715 -8716 -8717 -8718 -8719 -872 -8720 -8721 -8722 -8723 -8724 -8725 -8726 -8727 -8728 -8729 -873 -8730 -8731 -8732 -8733 -8734 -8735 -8736 -8737 -8738 -8739 -874 -8740 -8741 -8742 -8743 -8744 -8745 -8746 -8747 -8748 -8749 -875 -8750 -8751 -8752 -8753 -8754 -8755 -8756 -8757 -8758 -8759 -876 -8760 -8761 -8762 -8763 -8764 -8765 -8766 -8767 -8768 -8769 -877 -8770 -8771 -8772 -8773 -8774 -8775 -8776 -8777 -8778 -8779 -878 -8780 -8781 -8782 -8783 -8784 -8785 -8786 -8787 -8788 -8789 -879 -8790 -8791 -8792 -8793 -8794 -8795 -8796 -8797 -8798 -8799 -88 -880 -8800 -8801 -8802 -8803 -8804 -8805 -8806 -8807 -8808 -8809 -881 -8810 -8811 -8812 -8813 -8814 -8815 -8816 -8817 -8818 -8819 -882 -8820 -8821 -8822 -8823 -8824 -8825 -8826 -8827 -8828 -8829 -883 -8830 -8831 -8832 -8833 -8834 -8835 -8836 -8837 -8838 -8839 -884 -8840 -8841 -8842 -8843 -8844 -8845 -8846 -8847 -8848 -8849 -885 -8850 -8851 -8852 -8853 -8854 -8855 -8856 -8857 -8858 -8859 -886 -8860 -8861 -8862 -8863 -8864 -8865 -8866 -8867 -8868 -8869 -887 -8870 -8871 -8872 -8873 -8874 -8875 -8876 -8877 -8878 -8879 -888 -8880 -8881 -8882 -8883 -8884 -8885 -8886 -8887 -8888 -8889 -889 -8890 -8891 -8892 -8893 -8894 -8895 -8896 -8897 -8898 -8899 -89 -890 -8900 -8901 -8902 -8903 -8904 -8905 -8906 -8907 -8908 -8909 -891 -8910 -8911 -8912 -8913 -8914 -8915 -8916 -8917 -8918 -8919 -892 -8920 -8921 -8922 -8923 -8924 -8925 -8926 -8927 -8928 -8929 -893 -8930 -8931 -8932 -8933 -8934 -8935 -8936 -8937 -8938 -8939 -894 -8940 -8941 -8942 -8943 -8944 -8945 -8946 -8947 -8948 -8949 -895 -8950 -8951 -8952 -8953 -8954 -8955 -8956 -8957 -8958 -8959 -896 -8960 -8961 -8962 -8963 -8964 -8965 -8966 -8967 -8968 -8969 -897 -8970 -8971 -8972 -8973 -8974 -8975 -8976 -8977 -8978 -8979 -898 -8980 -8981 -8982 -8983 -8984 -8985 -8986 -8987 -8988 -8989 -899 -8990 -8991 -8992 -8993 -8994 -8995 -8996 -8997 -8998 -8999 -9 -90 -900 -9000 -9001 -9002 -9003 -9004 -9005 -9006 -9007 -9008 -9009 -901 -9010 -9011 -9012 -9013 -9014 -9015 -9016 -9017 -9018 -9019 -902 -9020 -9021 -9022 -9023 -9024 -9025 -9026 -9027 -9028 -9029 -903 -9030 -9031 -9032 -9033 -9034 -9035 -9036 -9037 -9038 -9039 -904 -9040 -9041 -9042 -9043 -9044 -9045 -9046 -9047 -9048 -9049 -905 -9050 -9051 -9052 -9053 -9054 -9055 -9056 -9057 -9058 -9059 -906 -9060 -9061 -9062 -9063 -9064 -9065 -9066 -9067 -9068 -9069 -907 -9070 -9071 -9072 -9073 -9074 -9075 -9076 -9077 -9078 -9079 -908 -9080 -9081 -9082 -9083 -9084 -9085 -9086 -9087 -9088 -9089 -909 -9090 -9091 -9092 -9093 -9094 -9095 -9096 -9097 -9098 -9099 -91 -910 -9100 -9101 -9102 -9103 -9104 -9105 -9106 -9107 -9108 -9109 -911 -9110 -9111 -9112 -9113 -9114 -9115 -9116 -9117 -9118 -9119 -912 -9120 -9121 -9122 -9123 -9124 -9125 -9126 -9127 -9128 -9129 -913 -9130 -9131 -9132 -9133 -9134 -9135 -9136 -9137 -9138 -9139 -914 -9140 -9141 -9142 -9143 -9144 -9145 -9146 -9147 -9148 -9149 -915 -9150 -9151 -9152 -9153 -9154 -9155 -9156 -9157 -9158 -9159 -916 -9160 -9161 -9162 -9163 -9164 -9165 -9166 -9167 -9168 -9169 -917 -9170 -9171 -9172 -9173 -9174 -9175 -9176 -9177 -9178 -9179 -918 -9180 -9181 -9182 -9183 -9184 -9185 -9186 -9187 -9188 -9189 -919 -9190 -9191 -9192 -9193 -9194 -9195 -9196 -9197 -9198 -9199 -92 -920 -9200 -9201 -9202 -9203 -9204 -9205 -9206 -9207 -9208 -9209 -921 -9210 -9211 -9212 -9213 -9214 -9215 -9216 -9217 -9218 -9219 -922 -9220 -9221 -9222 -9223 -9224 -9225 -9226 -9227 -9228 -9229 -923 -9230 -9231 -9232 -9233 -9234 -9235 -9236 -9237 -9238 -9239 -924 -9240 -9241 -9242 -9243 -9244 -9245 -9246 -9247 -9248 -9249 -925 -9250 -9251 -9252 -9253 -9254 -9255 -9256 -9257 -9258 -9259 -926 -9260 -9261 -9262 -9263 -9264 -9265 -9266 -9267 -9268 -9269 -927 -9270 -9271 -9272 -9273 -9274 -9275 -9276 -9277 -9278 -9279 -928 -9280 -9281 -9282 -9283 -9284 -9285 -9286 -9287 -9288 -9289 -929 -9290 -9291 -9292 -9293 -9294 -9295 -9296 -9297 -9298 -9299 -93 -930 -9300 -9301 -9302 -9303 -9304 -9305 -9306 -9307 -9308 -9309 -931 -9310 -9311 -9312 -9313 -9314 -9315 -9316 -9317 -9318 -9319 -932 -9320 -9321 -9322 -9323 -9324 -9325 -9326 -9327 -9328 -9329 -933 -9330 -9331 -9332 -9333 -9334 -9335 -9336 -9337 -9338 -9339 -934 -9340 -9341 -9342 -9343 -9344 -9345 -9346 -9347 -9348 -9349 -935 -9350 -9351 -9352 -9353 -9354 -9355 -9356 -9357 -9358 -9359 -936 -9360 -9361 -9362 -9363 -9364 -9365 -9366 -9367 -9368 -9369 -937 -9370 -9371 -9372 -9373 -9374 -9375 -9376 -9377 -9378 -9379 -938 -9380 -9381 -9382 -9383 -9384 -9385 -9386 -9387 -9388 -9389 -939 -9390 -9391 -9392 -9393 -9394 -9395 -9396 -9397 -9398 -9399 -94 -940 -9400 -9401 -9402 -9403 -9404 -9405 -9406 -9407 -9408 -9409 -941 -9410 -9411 -9412 -9413 -9414 -9415 -9416 -9417 -9418 -9419 -942 -9420 -9421 -9422 -9423 -9424 -9425 -9426 -9427 -9428 -9429 -943 -9430 -9431 -9432 -9433 -9434 -9435 -9436 -9437 -9438 -9439 -944 -9440 -9441 -9442 -9443 -9444 -9445 -9446 -9447 -9448 -9449 -945 -9450 -9451 -9452 -9453 -9454 -9455 -9456 -9457 -9458 -9459 -946 -9460 -9461 -9462 -9463 -9464 -9465 -9466 -9467 -9468 -9469 -947 -9470 -9471 -9472 -9473 -9474 -9475 -9476 -9477 -9478 -9479 -948 -9480 -9481 -9482 -9483 -9484 -9485 -9486 -9487 -9488 -9489 -949 -9490 -9491 -9492 -9493 -9494 -9495 -9496 -9497 -9498 -9499 -95 -950 -9500 -9501 -9502 -9503 -9504 -9505 -9506 -9507 -9508 -9509 -951 -9510 -9511 -9512 -9513 -9514 -9515 -9516 -9517 -9518 -9519 -952 -9520 -9521 -9522 -9523 -9524 -9525 -9526 -9527 -9528 -9529 -953 -9530 -9531 -9532 -9533 -9534 -9535 -9536 -9537 -9538 -9539 -954 -9540 -9541 -9542 -9543 -9544 -9545 -9546 -9547 -9548 -9549 -955 -9550 -9551 -9552 -9553 -9554 -9555 -9556 -9557 -9558 -9559 -956 -9560 -9561 -9562 -9563 -9564 -9565 -9566 -9567 -9568 -9569 -957 -9570 -9571 -9572 -9573 -9574 -9575 -9576 -9577 -9578 -9579 -958 -9580 -9581 -9582 -9583 -9584 -9585 -9586 -9587 -9588 -9589 -959 -9590 -9591 -9592 -9593 -9594 -9595 -9596 -9597 -9598 -9599 -96 -960 -9600 -9601 -9602 -9603 -9604 -9605 -9606 -9607 -9608 -9609 -961 -9610 -9611 -9612 -9613 -9614 -9615 -9616 -9617 -9618 -9619 -962 -9620 -9621 -9622 -9623 -9624 -9625 -9626 -9627 -9628 -9629 -963 -9630 -9631 -9632 -9633 -9634 -9635 -9636 -9637 -9638 -9639 -964 -9640 -9641 -9642 -9643 -9644 -9645 -9646 -9647 -9648 -9649 -965 -9650 -9651 -9652 -9653 -9654 -9655 -9656 -9657 -9658 -9659 -966 -9660 -9661 -9662 -9663 -9664 -9665 -9666 -9667 -9668 -9669 -967 -9670 -9671 -9672 -9673 -9674 -9675 -9676 -9677 -9678 -9679 -968 -9680 -9681 -9682 -9683 -9684 -9685 -9686 -9687 -9688 -9689 -969 -9690 -9691 -9692 -9693 -9694 -9695 -9696 -9697 -9698 -9699 -97 -970 -9700 -9701 -9702 -9703 -9704 -9705 -9706 -9707 -9708 -9709 -971 -9710 -9711 -9712 -9713 -9714 -9715 -9716 -9717 -9718 -9719 -972 -9720 -9721 -9722 -9723 -9724 -9725 -9726 -9727 -9728 -9729 -973 -9730 -9731 -9732 -9733 -9734 -9735 -9736 -9737 -9738 -9739 -974 -9740 -9741 -9742 -9743 -9744 -9745 -9746 -9747 -9748 -9749 -975 -9750 -9751 -9752 -9753 -9754 -9755 -9756 -9757 -9758 -9759 -976 -9760 -9761 -9762 -9763 -9764 -9765 -9766 -9767 -9768 -9769 -977 -9770 -9771 -9772 -9773 -9774 -9775 -9776 -9777 -9778 -9779 -978 -9780 -9781 -9782 -9783 -9784 -9785 -9786 -9787 -9788 -9789 -979 -9790 -9791 -9792 -9793 -9794 -9795 -9796 -9797 -9798 -9799 -98 -980 -9800 -9801 -9802 -9803 -9804 -9805 -9806 -9807 -9808 -9809 -981 -9810 -9811 -9812 -9813 -9814 -9815 -9816 -9817 -9818 -9819 -982 -9820 -9821 -9822 -9823 -9824 -9825 -9826 -9827 -9828 -9829 -983 -9830 -9831 -9832 -9833 -9834 -9835 -9836 -9837 -9838 -9839 -984 -9840 -9841 -9842 -9843 -9844 -9845 -9846 -9847 -9848 -9849 -985 -9850 -9851 -9852 -9853 -9854 -9855 -9856 -9857 -9858 -9859 -986 -9860 -9861 -9862 -9863 -9864 -9865 -9866 -9867 -9868 -9869 -987 -9870 -9871 -9872 -9873 -9874 -9875 -9876 -9877 -9878 -9879 -988 -9880 -9881 -9882 -9883 -9884 -9885 -9886 -9887 -9888 -9889 -989 -9890 -9891 -9892 -9893 -9894 -9895 -9896 -9897 -9898 -9899 -99 -990 -9900 -9901 -9902 -9903 -9904 -9905 -9906 -9907 -9908 -9909 -991 -9910 -9911 -9912 -9913 -9914 -9915 -9916 -9917 -9918 -9919 -992 -9920 -9921 -9922 -9923 -9924 -9925 -9926 -9927 -9928 -9929 -993 -9930 -9931 -9932 -9933 -9934 -9935 -9936 -9937 -9938 -9939 -994 -9940 -9941 -9942 -9943 -9944 -9945 -9946 -9947 -9948 -9949 -995 -9950 -9951 -9952 -9953 -9954 -9955 -9956 -9957 -9958 -9959 -996 -9960 -9961 -9962 -9963 -9964 -9965 -9966 -9967 -9968 -9969 -997 -9970 -9971 -9972 -9973 -9974 -9975 -9976 -9977 -9978 -9979 -998 -9980 -9981 -9982 -9983 -9984 -9985 -9986 -9987 -9988 -9989 -999 -9990 -9991 -9992 -9993 -9994 -9995 -9996 -9997 -9998 -9999 - - --- !query 56 -SELECT count() OVER () FROM tenk1 --- !query 56 schema -struct --- !query 56 output -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 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 -0 -0 - - --- !query 57 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 57 schema +-- !query 55 schema struct --- !query 57 output +-- !query 55 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 58 +-- !query 56 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 58 schema +-- !query 56 schema struct --- !query 58 output +-- !query 56 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 59 +-- !query 57 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 59 schema +-- !query 57 schema struct --- !query 59 output +-- !query 57 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 60 +-- !query 58 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 60 schema +-- !query 58 schema struct --- !query 60 output +-- !query 58 output 1 2 2 2.5 3 NULL 4 NULL --- !query 61 +-- !query 59 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 61 schema +-- !query 59 schema struct --- !query 61 output +-- !query 59 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 62 +-- !query 60 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 62 schema +-- !query 60 schema struct --- !query 62 output +-- !query 60 output 1 3 2 2 3 NULL 4 NULL --- !query 63 +-- !query 61 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 63 schema +-- !query 61 schema struct --- !query 63 output +-- !query 61 output 1 3 2 2 3 NULL 4 NULL --- !query 64 +-- !query 62 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 64 schema +-- !query 62 schema struct --- !query 64 output +-- !query 62 output 1 3 2 2 3 NULL 4 NULL --- !query 65 +-- !query 63 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 65 schema +-- !query 63 schema struct --- !query 65 output +-- !query 63 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 66 +-- !query 64 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 66 schema +-- !query 64 schema struct --- !query 66 output +-- !query 64 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 67 +-- !query 65 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 67 schema +-- !query 65 schema struct --- !query 67 output +-- !query 65 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 68 +-- !query 66 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 68 schema +-- !query 66 schema struct --- !query 68 output +-- !query 66 output 3 5 6.01 --- !query 69 +-- !query 67 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 69 schema +-- !query 67 schema struct --- !query 69 output +-- !query 67 output 1 2 2 1 3 0 4 0 --- !query 70 +-- !query 68 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 70 schema +-- !query 68 schema struct --- !query 70 output +-- !query 68 output 1 4 2 3 3 2 4 1 --- !query 71 +-- !query 69 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 71 schema +-- !query 69 schema struct --- !query 71 output +-- !query 69 output 0.0 11266.666666666666 13868.750000000002 @@ -21114,12 +1100,12 @@ struct --- !query 72 output +-- !query 70 output 0.0 11266.666666666666 13868.750000000002 @@ -21127,12 +1113,12 @@ struct --- !query 73 output +-- !query 71 output 0.0 11266.666666666666 13868.750000000002 @@ -21140,12 +1126,12 @@ struct --- !query 74 output +-- !query 72 output 0.0 11266.666666666666 13868.750000000002 @@ -21153,12 +1139,12 @@ struct --- !query 75 output +-- !query 73 output 16900.0 18491.666666666668 27129.999999999996 @@ -21166,12 +1152,12 @@ struct --- !query 76 output +-- !query 74 output 16900.0 18491.666666666668 27129.999999999996 @@ -21179,12 +1165,12 @@ struct --- !query 77 output +-- !query 75 output 16900.0 18491.666666666668 27129.999999999996 @@ -21192,12 +1178,12 @@ struct --- !query 78 output +-- !query 76 output 16900.0 18491.666666666668 27129.999999999996 @@ -21205,12 +1191,12 @@ struct --- !query 79 output +-- !query 77 output 16900.0 18491.666666666668 27129.999999999996 @@ -21218,12 +1204,12 @@ struct --- !query 80 output +-- !query 78 output 16900.0 18491.666666666668 27129.999999999996 @@ -21231,12 +1217,12 @@ struct --- !query 81 output +-- !query 79 output 16900.0 18491.666666666668 27129.999999999996 @@ -21244,12 +1230,12 @@ struct --- !query 82 output +-- !query 80 output 16900.0 18491.666666666668 27129.999999999996 @@ -21257,12 +1243,12 @@ struct --- !query 83 output +-- !query 81 output 0.0 106.14455552060438 117.76565713313879 @@ -21271,12 +1257,12 @@ struct --- !query 84 output +-- !query 82 output 0.0 106.14455552060438 117.76565713313879 @@ -21285,12 +1271,12 @@ struct --- !query 85 output +-- !query 83 output 0.0 106.14455552060438 117.76565713313879 @@ -21299,12 +1285,12 @@ struct --- !query 86 output +-- !query 84 output 0.0 106.14455552060438 117.76565713313879 @@ -21313,12 +1299,12 @@ struct --- !query 87 output +-- !query 85 output 130.0 135.9840676942217 164.7118696390761 @@ -21327,12 +1313,12 @@ struct --- !query 88 output +-- !query 86 output 130.0 135.9840676942217 164.7118696390761 @@ -21341,12 +1327,12 @@ struct --- !query 89 output +-- !query 87 output 130.0 135.9840676942217 164.7118696390761 @@ -21355,12 +1341,12 @@ struct --- !query 90 output +-- !query 88 output 130.0 135.9840676942217 164.7118696390761 @@ -21369,12 +1355,12 @@ struct --- !query 91 output +-- !query 89 output 130.0 135.9840676942217 164.7118696390761 @@ -21383,12 +1369,12 @@ struct --- !query 92 output +-- !query 90 output 130.0 135.9840676942217 164.7118696390761 @@ -21397,12 +1383,12 @@ struct --- !query 93 output +-- !query 91 output 130.0 135.9840676942217 164.7118696390761 @@ -21411,12 +1397,12 @@ struct --- !query 94 output +-- !query 92 output 130.0 135.9840676942217 164.7118696390761 @@ -21425,61 +1411,61 @@ struct --- !query 95 output +-- !query 93 output 1 1 2 2 3 NULL 4 NULL --- !query 96 +-- !query 94 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 96 schema +-- !query 94 schema struct --- !query 96 output +-- !query 94 output 1 3 2 2 3 NULL 4 NULL --- !query 97 +-- !query 95 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 97 schema +-- !query 95 schema struct --- !query 97 output +-- !query 95 output 1 3 2 6 3 9 4 7 --- !query 98 +-- !query 96 drop table empsalary --- !query 98 schema +-- !query 96 schema struct<> --- !query 98 output +-- !query 96 output --- !query 99 +-- !query 97 drop table t1 --- !query 99 schema +-- !query 97 schema struct<> --- !query 99 output +-- !query 97 output --- !query 100 +-- !query 98 drop view int4_tbl --- !query 100 schema +-- !query 98 schema struct<> --- !query 100 output +-- !query 98 output From 331a8ac3edc968ce36f082a82c3acf8e4ffa7e8d Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 17 Jul 2019 10:41:39 -0300 Subject: [PATCH 08/25] update sqlwindow tests Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 593 ++++++----- .../sql-tests/results/pgSQL/window.sql.out | 971 +++++++++++++----- 2 files changed, 1020 insertions(+), 544 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index d2ce5edd2afe2..1a40e74396342 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -1,12 +1,8 @@ --- -- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group -- -- Window Functions Testing -- https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/window.sql --- The queries that are not (fully) available at Spark, I added an [ERROR] tag, so if you --- are looking for queries to fix, you can just look for ERROR. - CREATE TABLE empsalary ( depname string, empno integer, @@ -36,7 +32,7 @@ GROUP BY four, ten ORDER BY four, ten; SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname); -- [SPARK-28064] Order by does not accept a call to rank() --- [ERROR] SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w; +-- SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w; SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10; @@ -59,14 +55,13 @@ SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 W SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10; -- [SPARK-28065] ntile does not accept NULL as input --- [ERROR] SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; +-- SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; --- Spark fills with NULL instead of white space SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -- [SPARK-28068] `lag` second argument must be a literal in Spark --- [ERROR] SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; --- [ERROR] SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +-- SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +-- SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; @@ -74,16 +69,16 @@ SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM te SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +SELECT first(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +SELECT last(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; -SELECT last_value(ten) OVER (PARTITION BY four), ten, four FROM +SELECT last(ten) OVER (PARTITION BY four), ten, four FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s ORDER BY four, ten; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four -- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s; SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER (PARTITION BY two ORDER BY ten) AS wsum @@ -116,21 +111,22 @@ FROM empsalary GROUP BY depname; SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); --- --- [ERROR] SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) +-- Correlated scalar subqueries must be aggregated: Filter (outer(unique2#x) = unique2#x) +-- SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) -- FROM tenk1 s WHERE unique2 < 10; SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s; SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC); -SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( - SELECT *, - CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus, - CASE WHEN - AVG(salary) OVER (PARTITION BY depname) < salary - THEN 200 END AS depadj FROM empsalary - )s; +-- no viable alternative at input 'year' +-- SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( +-- SELECT *, +-- CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(year FROM enroll_date) END * 500 AS bonus, +-- CASE WHEN +-- AVG(salary) OVER (PARTITION BY depname) < salary +-- THEN 200 END AS depadj FROM empsalary +-- )s; create temporary view int4_tbl as select * from values (0), @@ -148,33 +144,33 @@ select ten, from tenk1 group by ten order by ten; -select first_value(max(x)) over (), y +select first(max(x)) over (), y from (select unique1 as x, ten+four as y from tenk1) ss group by y; SELECT four, ten, sum(ten) over (partition by four order by ten), -last_value(ten) over (partition by four order by ten) +last(ten) over (partition by four order by ten) FROM (select distinct ten, four from tenk1) ss; SELECT four, ten, sum(ten) over (partition by four order by ten range between unbounded preceding and current row), -last_value(ten) over (partition by four order by ten range between unbounded preceding and current row) +last(ten) over (partition by four order by ten range between unbounded preceding and current row) FROM (select distinct ten, four from tenk1) ss; SELECT four, ten, sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following), -last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) +last(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) FROM (select distinct ten, four from tenk1) ss; SELECT four, ten/4 as two, sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row), -last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row) +last(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row) FROM (select distinct ten, four from tenk1) ss; SELECT four, ten/4 as two, sum(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row), -last_value(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) +last(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) FROM (select distinct ten, four from tenk1) ss; SELECT sum(unique1) over (order by four range between current row and unbounded following), @@ -189,445 +185,491 @@ SELECT sum(unique1) over (rows between 2 preceding and 2 following), unique1, four FROM tenk1 WHERE unique1 < 10; --- Error in the following queries. --- Related with `exclude` or the `following` --- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; --- SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), +-- missing ')' at 'exclude' +-- SELECT first(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), +-- missing ')' at 'exclude' +-- SELECT first(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), +-- missing ')' at 'exclude' +-- SELECT first(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), +-- missing ')' at 'exclude' +-- SELECT last(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), +-- missing ')' at 'exclude' +-- SELECT last(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), +-- missing ')' at 'exclude' +-- SELECT last(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (rows between 1 following and 3 following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (rows between unbounded preceding and 1 following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (rows between 1 following and 3 following), +unique1, four +FROM tenk1 WHERE unique1 < 10; + +SELECT sum(unique1) over (rows between unbounded preceding and 1 following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- Spark does not accept the window definition too far? --- [ERROR] SELECT sum(unique1) over (w range between current row and unbounded following), +--mismatched input '(' +-- SELECT sum(unique1) over (w range between current row and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- [ERROR] SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), +-- mismatched input '(' e +-- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- [ERROR] SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), +-- mismatched input '(' e +-- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- [ERROR] SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), +-- mismatched input '(' e +-- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] SELECT first_value(unique1) over w, + +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- SELECT first_value(unique1) over w, -- nth_value(unique1, 2) over w AS nth_2, -- last_value(unique1) over w, unique1, four -- FROM tenk1 WHERE unique1 < 10 -- WINDOW w AS (order by four range between current row and unbounded following); --- [ERROR] SELECT sum(unique1) over +-- Frame bound value must be a literal. +-- SELECT sum(unique1) over -- (order by unique1 -- rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), -- unique1 -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] CREATE TEMP VIEW v_window AS --- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following) as sum_rows --- FROM range(1, 10) i; +CREATE TEMP VIEW v_window AS +SELECT i.id, sum(i.id) over (order by i.id rows between 1 preceding and 1 following) as sum_rows +FROM range(1, 10) i; --- [ERROR] SELECT * FROM v_window; +SELECT * FROM v_window; --- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS +-- missing ')' at 'exclude' +-- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude current row) as sum_rows FROM range(1, 10) i; --- [ERROR] SELECT * FROM v_window; +SELECT * FROM v_window; --- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS +-- missing ')' at 'exclude' +-- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude group) as sum_rows FROM range(1, 10) i; --- [ERROR] SELECT * FROM v_window; +SELECT * FROM v_window; --- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS +-- missing ')' at 'exclude' +-- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude ties) as sum_rows FROM generate_series(1, 10) i; --- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS +-- missing ')' at 'exclude' +-- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude no others) as sum_rows FROM generate_series(1, 10) i; --- [ERROR] SELECT * FROM v_window; - --- [ERROR] CREATE OR REPLACE TEMP VIEW v_window AS --- SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM generate_series(1, 10) i; - --- [ERROR] SELECT * FROM v_window; +SELECT * FROM v_window; --- [ERROR] SELECT pg_get_viewdef('v_window'); +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i; +-- +-- SELECT * FROM v_window; --- [ERROR] DROP VIEW v_window; +DROP VIEW v_window; --- [ERROR] CREATE TEMP VIEW v_window AS +-- cannot resolve '(current_timestamp() + CAST('100 days' AS DOUBLE))' due to data type mismatch: differing types in '(current_timestamp() + CAST('100 days' AS DOUBLE))' (timestamp and double).; +-- CREATE TEMP VIEW v_window AS -- SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i --- FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i; +-- FROM range(now(), now()+'100 days', '1 hour') i; --- RANGE offset PRECEDING/FOLLOWING tests --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (order by four range between 2 preceding and 6 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group), +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (order by four range between 2 preceding and 6 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; --- --- [ERROR] SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following +SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), +unique1, four +FROM tenk1 WHERE unique1 < 10; + +-- missing ')' at 'exclude' +-- SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following -- exclude current row),unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following), +-- cannot resolve 'RANGE BETWEEN CAST('1 year' AS DOUBLE) PRECEDING AND '1 year' FOLLOWING' due to data type mismatch: The data type of the upper bound 'string' does not match the expected data type '(numeric or calendarinterval)'.; +-- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following), -- salary, enroll_date from empsalary; --- [ERROR] select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following), +-- cannot resolve 'RANGE BETWEEN CAST('1 year' AS DOUBLE) PRECEDING AND '1 year' FOLLOWING' due to data type mismatch: The data type of the upper bound 'string' does not match the expected data type '(numeric or calendarinterval)'.; +-- select sum(salary) over (order by enroll_date desc range between '1 year' preceding and '1 year' following), -- salary, enroll_date from empsalary; --- [ERROR] select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following), +-- cannot resolve 'RANGE BETWEEN '1 year' FOLLOWING AND '1 year' FOLLOWING' due to data type mismatch: The data type of the lower bound 'string' does not match the expected data type '(numeric or calendarinterval)'.; +-- select sum(salary) over (order by enroll_date desc range between '1 year' following and '1 year' following), -- salary, enroll_date from empsalary; --- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following -- exclude current row), salary, enroll_date from empsalary; --- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following -- exclude group), salary, enroll_date from empsalary; --- [ERROR] select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following -- exclude ties), salary, enroll_date from empsalary; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), -- lead(salary) over(order by salary range between 1000 preceding and 1000 following), -- nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following), -- salary from empsalary; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), -- lag(salary) over(order by salary range between 1000 preceding and 1000 following), -- salary from empsalary; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] select first_value(salary) over(order by salary range between 1000 following and 3000 following +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- select first_value(salary) over(order by salary range between 1000 following and 3000 following -- exclude current row), -- lead(salary) over(order by salary range between 1000 following and 3000 following exclude ties), -- nth_value(salary, 1) over(order by salary range between 1000 following and 3000 following -- exclude ties), -- salary from empsalary; --- [ERROR] select last_value(salary) over(order by salary range between 1000 following and 3000 following +-- missing ')' at 'exclude' +-- select last(salary) over(order by salary range between 1000 following and 3000 following -- exclude group), -- lag(salary) over(order by salary range between 1000 following and 3000 following exclude group), -- salary from empsalary; --- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude ties), --- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following), +-- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following), -- salary, enroll_date from empsalary; --- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude ties), --- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude ties), -- salary, enroll_date from empsalary; --- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude group), --- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude group), -- salary, enroll_date from empsalary; --- [ERROR] select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- missing ')' at 'exclude' +-- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude current row), --- last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following +-- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude current row), -- salary, enroll_date from empsalary; -- in Spark, x is ambiguous for the following queries --- [ERROR] select x, y, --- first_value(y) over w, --- last_value(y) over w --- from --- (select x, x as y from range(1,5) as x --- union all select null, 42 --- union all select null, 43) ss --- window w as --- (order by x asc nulls first range between 2 preceding and 2 following); - --- [ERROR] select x, y, --- first_value(y) over w, --- last_value(y) over w --- from --- (select x, x as y from range(1,5) as x --- union all select null, 42 --- union all select null, 43) ss --- window w as --- (order by x asc nulls last range between 2 preceding and 2 following); - --- [ERROR] select x, y, --- first_value(y) over w, --- last_value(y) over w --- from --- (select x, x as y from range(1,5) as x --- union all select null, 42 --- union all select null, 43) ss --- window w as --- (order by x desc nulls first range between 2 preceding and 2 following); - --- [ERROR] select x, y, --- first_value(y) over w, --- last_value(y) over w --- from --- (select x, x as y from range(1,5) as x --- union all select null, 42 --- union all select null, 43) ss --- window w as --- (order by x desc nulls last range between 2 preceding and 2 following); - --- Check overflow behavior for various integer sizes --- [ERROR] select x, last_value(x) over (order by x range between current row and 2147450884 following) --- from range(32764, 32766) x; - --- Spark does not define default column name as the name of the sub-query --- instead, it calls the default column for `range()` as id -select x.id, last_value(x.id) over (order by x.id desc range between current row and 2147450885 following) +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id asc nulls first range between 2 preceding and 2 following); + +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id asc nulls last range between 2 preceding and 2 following); + +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id desc nulls first range between 2 preceding and 2 following); + +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id desc nulls last range between 2 preceding and 2 following); + +select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) +from range(32764, 32766) x; + +select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) from range(-32766, -32764) x; -select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x; -select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x; -select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x; -select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x; --- GROUPS tests --- no `groups`? --- [ERROR] SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between current row and unbounded following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between current row and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude current row), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude group), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude ties), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (partition by ten +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following),unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (partition by ten +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (partition by ten +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- [ERROR] SELECT sum(unique1) over (partition by ten +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- SELECT sum(unique1) over (partition by ten -- order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- [ERROR] select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- select last(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] select first_value(salary) over(order by enroll_date groups between 1 following and 3 following +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- select first_value(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude current row), -- lead(salary) over(order by enroll_date groups between 1 following and 3 following exclude ties), -- nth_value(salary, 1) over(order by enroll_date groups between 1 following and 3 following -- exclude ties), -- salary, enroll_date from empsalary; --- [ERROR] select last_value(salary) over(order by enroll_date groups between 1 following and 3 following +-- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- select last(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude group), -- lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), -- salary, enroll_date from empsalary; --- Show differences in offset interpretation between ROWS, RANGE, and GROUPS --- [ERROR] WITH cte (x) AS ( --- SELECT * FROM generate_series(1, 35, 2) --- ) --- SELECT x, (sum(x) over w) --- FROM cte --- WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); - --- [ERROR] WITH cte (x) AS ( --- SELECT * FROM generate_series(1, 35, 2) --- ) --- SELECT x, (sum(x) over w) --- FROM cte --- WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); - --- [ERROR] WITH cte (x) AS ( --- SELECT * FROM generate_series(1, 35, 2) +WITH cte (x) AS ( + SELECT * FROM range(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); + +WITH cte (x) AS ( + SELECT * FROM range(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); + +-- mismatched input 'WINDOW' expecting {, 'LIMIT'} +-- WITH cte (x) AS ( +-- SELECT * FROM range(1, 35, 2) -- ) -- SELECT x, (sum(x) over w) -- FROM cte -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); --- [ERROR] WITH cte (x) AS ( --- select 1 union all select 1 union all select 1 union all --- SELECT * FROM generate_series(5, 49, 2) --- ) --- SELECT x, (sum(x) over w) --- FROM cte --- WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); - --- [ERROR] WITH cte (x) AS ( --- select 1 union all select 1 union all select 1 union all --- SELECT * FROM generate_series(5, 49, 2) --- ) --- SELECT x, (sum(x) over w) --- FROM cte --- WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); - --- [ERROR] WITH cte (x) AS ( +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM range(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); + +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM range(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); + +-- mismatched input 'WINDOW' expecting {, 'LIMIT'} +-- WITH cte (x) AS ( -- select 1 union all select 1 union all select 1 union all --- SELECT * FROM generate_series(5, 49, 2) +-- SELECT * FROM range(5, 49, 2) -- ) -- SELECT x, (sum(x) over w) -- FROM cte -- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); --- with UNION SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); --- broken - costs and range are not available? --- [ERROR] select f1, sum(f1) over (partition by f1 +-- broken - costs not available +-- select f1, sum(f1) over (partition by f1 -- range between 1 preceding and 1 following) -- from t1 where f1 = f2; --- [ERROR] explain (costs off) +-- explain (costs off) -- select f1, sum(f1) over (partition by f1 order by f2 -- range between 1 preceding and 1 following) -- from t1 where f1 = f2; @@ -635,80 +677,88 @@ insert into t1 values (1,1),(1,2),(2,2); -- range between 1 preceding and 1 following) -- from t1 where f1 = f2; --- [ERROR] select f1, sum(f1) over (partition by f1, f1 order by f2 --- range between 2 preceding and 1 preceding) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1, f1 order by f2 +range between 2 preceding and 1 preceding) +from t1 where f1 = f2; --- [ERROR] select f1, sum(f1) over (partition by f1, f2 order by f2 --- range between 1 following and 2 following) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) +from t1 where f1 = f2; --- [ERROR] select f1, sum(f1) over (partition by f1 +-- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} +-- select f1, sum(f1) over (partition by f1 -- groups between 1 preceding and 1 following) -- from t1 where f1 = f2; --- [ERROR] explain (costs off) +-- explain(costs off) not available +-- explain (costs off) -- select f1, sum(f1) over (partition by f1 order by f2 -- groups between 1 preceding and 1 following) -- from t1 where f1 = f2; --- [ERROR] select f1, sum(f1) over (partition by f1 order by f2 +-- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} +-- select f1, sum(f1) over (partition by f1 order by f2 -- groups between 1 preceding and 1 following) -- from t1 where f1 = f2; --- [ERROR] select f1, sum(f1) over (partition by f1, f1 order by f2 +-- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} +-- select f1, sum(f1) over (partition by f1, f1 order by f2 -- groups between 2 preceding and 1 preceding) -- from t1 where f1 = f2; - --- [ERROR] select f1, sum(f1) over (partition by f1, f2 order by f2 + +-- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} +-- select f1, sum(f1) over (partition by f1, f2 order by f2 -- groups between 1 following and 2 following) -- from t1 where f1 = f2; SELECT rank() OVER (ORDER BY length('abc')); -- [SPARK-28086] Adds `random()` to Spark --- [ERROR] SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); +-- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); --- some other errors --- [ERROR] SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; +-- It is not allowed to use window functions inside WHERE and HAVING clauses; +-- SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; --- [ERROR] SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; +-- The query operator `Join` contains one or more unsupported +-- expression types Aggregate, Window or Generate. +-- SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; --- [ERROR] SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; +-- The query operator `Aggregate` contains one or more unsupported +-- expression types Aggregate, Window or Generate. +-- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; -- [SPARK-28086] Adds `random()` to Spark --- [ERROR] SELECT * FROM rank() OVER (ORDER BY random()); - --- The output is not truncated? --- [ERROR] SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); +-- SELECT * FROM rank() OVER (ORDER BY random()); --- It does not work. Maybe it is related to not defining a window? --- [ERROR] SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; +-- Output not being truncated +-- SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); --- The output is not truncated? --- [ERROR] SELECT count() OVER () FROM tenk1; +-- Output not being truncated +-- SELECT rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1; +-- Output not being truncated +-- SELECT count() OVER () FROM tenk1; -- Ok, first I migrated a call to `generate_series()`, given by Postgres, to -- the equivalent Spark function, called `range()`. But `range()` seems less -- flexible than `generate_series()` --- [ERROR] SELECT range(1, 100) OVER () FROM empsalary; +-- SELECT range(1, 101) OVER () FROM empsalary; --- the error is weird --- [ERROR] SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; +-- cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; +-- SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; --- [SPARK-27764] Currently, Spark is missing nth_value --- [ERROR] SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; +-- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; --- FILTER does not work on spark? --- [ERROR] SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( +-- mismatched input 'FILTER' +-- SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( -- sum(salary) FILTER (WHERE enroll_date > '2007-01-01') -- ) FILTER (WHERE depname <> 'sales') OVER (ORDER BY depname DESC) AS "filtered_sum", -- depname -- FROM empsalary GROUP BY depname; --- costs off didn't work? --- [ERROR] EXPLAIN (COSTS OFF) +-- explain (costs off) not available +-- EXPLAIN (COSTS OFF) -- SELECT * FROM -- (SELECT depname, -- sum(salary) OVER (PARTITION BY depname) depsalary, @@ -716,7 +766,8 @@ SELECT rank() OVER (ORDER BY length('abc')); -- FROM empsalary) emp -- WHERE depname = 'sales'; --- [ERROR] EXPLAIN (COSTS OFF) +-- explain (costs off) not available +-- EXPLAIN (COSTS OFF) -- SELECT * FROM -- (SELECT depname, -- sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, @@ -724,7 +775,8 @@ SELECT rank() OVER (ORDER BY length('abc')); -- FROM empsalary) emp -- WHERE depname = 'sales'; --- [ERROR] EXPLAIN (COSTS OFF) +-- explain (costs off) not available +-- EXPLAIN (COSTS OFF) -- SELECT * FROM -- (SELECT depname, -- sum(salary) OVER (PARTITION BY depname order by empno) depsalary, @@ -732,7 +784,8 @@ SELECT rank() OVER (ORDER BY length('abc')); -- FROM empsalary) emp -- WHERE depname = 'sales'; --- [ERROR] EXPLAIN (COSTS OFF) +-- explain (costs off) not available +-- EXPLAIN (COSTS OFF) -- SELECT -- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), -- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) @@ -862,7 +915,7 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v); -- [SPARK-27880] Implement boolean aggregates(BOOL_AND, BOOL_OR and EVERY) --- [ERROR] SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w +-- SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w -- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) -- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index a585516b0c26a..e6dcaf7b08cf6 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 99 +-- Number of queries: 121 -- !query 0 @@ -342,7 +342,7 @@ struct -- !query 20 output @@ -359,7 +359,7 @@ struct -- !query 21 output @@ -376,7 +376,7 @@ struct -- !query 27 SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10 -- !query 27 schema -struct +struct -- !query 27 output 0.0 0.0 @@ -550,29 +550,6 @@ struct --- !query 33 output -1 sales 5000 1000 200 1000 200 -10 develop 5200 500 200 500 200 -11 develop 5200 500 200 500 200 -2 personnel 3900 1000 200 1000 200 -3 sales 4800 500 NULL 500 200 -4 sales 4800 500 NULL 500 200 -5 personnel 3500 500 NULL 500 200 -7 develop 4200 NULL NULL 500 200 -8 develop 6000 1000 200 500 200 -9 develop 4500 NULL NULL 500 200 - - --- !query 34 create temporary view int4_tbl as select * from values (0), (123456), @@ -580,29 +557,29 @@ create temporary view int4_tbl as select * from values (2147483647), (-2147483647) as int4_tbl(f1) --- !query 34 schema +-- !query 33 schema struct<> --- !query 34 output +-- !query 33 output --- !query 35 +-- !query 34 SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 --- !query 35 schema +-- !query 34 schema struct --- !query 35 output +-- !query 34 output 0 --- !query 36 +-- !query 35 select ten, sum(unique1) + sum(unique2) as res, rank() over (order by sum(unique1) + sum(unique2)) as rank from tenk1 group by ten order by ten --- !query 36 schema +-- !query 35 schema struct --- !query 36 output +-- !query 35 output 0 9976146 4 1 10114187 9 2 10059554 8 @@ -615,13 +592,13 @@ struct 9 10040184 7 --- !query 37 -select first_value(max(x)) over (), y +-- !query 36 +select first(max(x)) over (), y from (select unique1 as x, ten+four as y from tenk1) ss group by y --- !query 37 schema +-- !query 36 schema struct --- !query 37 output +-- !query 36 output 9980 0 9980 10 9980 12 @@ -631,14 +608,14 @@ struct --- !query 38 output +-- !query 37 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -661,14 +638,14 @@ struct --- !query 39 output +-- !query 38 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -691,14 +668,14 @@ struct --- !query 40 output +-- !query 39 output 0 0 20 8 0 2 20 8 0 4 20 8 @@ -721,73 +698,73 @@ struct --- !query 41 output -0 0.0 0.0 0.0 -0 0.5 0.5 0.5 -0 1.0 1.5 1.0 -0 1.5 3.0 1.5 -0 2.0 5.0 2.0 -1 0.25 0.25 0.25 -1 0.75 1.0 0.75 -1 1.25 2.25 1.25 -1 1.75 4.0 1.75 -1 2.25 6.25 2.25 -2 0.0 0.0 0.0 -2 0.5 0.5 0.5 -2 1.0 1.5 1.0 -2 1.5 3.0 1.5 -2 2.0 5.0 2.0 -3 0.25 0.25 0.25 -3 0.75 1.0 0.75 -3 1.25 2.25 1.25 -3 1.75 4.0 1.75 -3 2.25 6.25 2.25 +-- !query 40 schema +struct +-- !query 40 output +0 0 0 0 +0 0 0 0 +0 1 2 1 +0 1 2 1 +0 2 4 2 +1 0 0 0 +1 0 0 0 +1 1 2 1 +1 1 2 1 +1 2 4 2 +2 0 0 0 +2 0 0 0 +2 1 2 1 +2 1 2 1 +2 2 4 2 +3 0 0 0 +3 0 0 0 +3 1 2 1 +3 1 2 1 +3 2 4 2 --- !query 42 +-- !query 41 SELECT four, ten/4 as two, sum(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row), -last_value(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) +last(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) FROM (select distinct ten, four from tenk1) ss --- !query 42 schema -struct --- !query 42 output -0 0.0 0.0 0.0 -0 0.5 0.5 0.5 -0 1.0 1.5 1.0 -0 1.5 3.0 1.5 -0 2.0 5.0 2.0 -1 0.25 0.25 0.25 -1 0.75 1.0 0.75 -1 1.25 2.25 1.25 -1 1.75 4.0 1.75 -1 2.25 6.25 2.25 -2 0.0 0.0 0.0 -2 0.5 0.5 0.5 -2 1.0 1.5 1.0 -2 1.5 3.0 1.5 -2 2.0 5.0 2.0 -3 0.25 0.25 0.25 -3 0.75 1.0 0.75 -3 1.25 2.25 1.25 -3 1.75 4.0 1.75 -3 2.25 6.25 2.25 +-- !query 41 schema +struct +-- !query 41 output +0 0 0 0 +0 0 0 0 +0 1 1 1 +0 1 2 1 +0 2 4 2 +1 0 0 0 +1 0 0 0 +1 1 1 1 +1 1 2 1 +1 2 4 2 +2 0 0 0 +2 0 0 0 +2 1 1 1 +2 1 2 1 +2 2 4 2 +3 0 0 0 +3 0 0 0 +3 1 1 1 +3 1 2 1 +3 2 4 2 --- !query 43 +-- !query 42 SELECT sum(unique1) over (order by four range between current row and unbounded following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 43 schema +-- !query 42 schema struct --- !query 43 output +-- !query 42 output 10 3 3 10 7 3 18 2 2 @@ -800,13 +777,13 @@ struct --- !query 44 output +-- !query 43 output 0 0 0 10 3 3 15 5 1 @@ -819,13 +796,13 @@ struct --- !query 45 output +-- !query 44 output 10 0 0 13 2 2 15 7 3 @@ -838,261 +815,707 @@ struct +-- !query 45 output +10 0 0 +13 3 3 +15 8 0 +17 5 1 +3 6 2 +4 2 2 +6 1 1 +7 9 1 +8 7 3 +NULL 4 0 + + -- !query 46 -select x.id, last_value(x.id) over (order by x.id desc range between current row and 2147450885 following) -from range(-32766, -32764) x +SELECT sum(unique1) over (rows between 1 following and 3 following), +unique1, four +FROM tenk1 WHERE unique1 < 10 -- !query 46 schema -struct +struct -- !query 46 output +0 7 3 +10 5 1 +15 8 0 +16 2 2 +16 9 1 +22 6 2 +23 1 1 +7 3 3 +9 4 0 +NULL 0 0 + + +-- !query 47 +SELECT sum(unique1) over (rows between unbounded preceding and 1 following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 47 schema +struct +-- !query 47 output +13 1 1 +22 6 2 +30 9 1 +35 8 0 +38 5 1 +45 0 0 +45 3 3 +45 7 3 +6 4 0 +7 2 2 + + +-- !query 48 +CREATE TEMP VIEW v_window AS +SELECT i.id, sum(i.id) over (order by i.id rows between 1 preceding and 1 following) as sum_rows +FROM range(1, 10) i +-- !query 48 schema +struct<> +-- !query 48 output + + + +-- !query 49 +SELECT * FROM v_window +-- !query 49 schema +struct +-- !query 49 output +1 3 +2 6 +3 9 +4 12 +5 15 +6 18 +7 21 +8 24 +9 17 + + +-- !query 50 +SELECT * FROM v_window +-- !query 50 schema +struct +-- !query 50 output +1 3 +2 6 +3 9 +4 12 +5 15 +6 18 +7 21 +8 24 +9 17 + + +-- !query 51 +SELECT * FROM v_window +-- !query 51 schema +struct +-- !query 51 output +1 3 +2 6 +3 9 +4 12 +5 15 +6 18 +7 21 +8 24 +9 17 + + +-- !query 52 +SELECT * FROM v_window +-- !query 52 schema +struct +-- !query 52 output +1 3 +2 6 +3 9 +4 12 +5 15 +6 18 +7 21 +8 24 +9 17 + + +-- !query 53 +DROP VIEW v_window +-- !query 53 schema +struct<> +-- !query 53 output + + + +-- !query 54 +SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 54 schema +struct +-- !query 54 output +12 1 1 +12 5 1 +12 9 1 +23 3 3 +23 7 3 +27 2 2 +27 6 2 +NULL 0 0 +NULL 4 0 +NULL 8 0 + + +-- !query 55 +SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 55 schema +struct +-- !query 55 output +10 2 2 +10 6 2 +18 1 1 +18 5 1 +18 9 1 +23 0 0 +23 4 0 +23 8 0 +NULL 3 3 +NULL 7 3 + + +-- !query 56 +SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 56 schema +struct +-- !query 56 output +10 3 3 +10 7 3 +12 4 0 +12 8 0 +14 9 1 +15 5 1 +4 0 0 +6 1 1 +8 2 2 +8 6 2 + + +-- !query 57 +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id asc nulls first range between 2 preceding and 2 following) +-- !query 57 schema +struct +-- !query 57 output +1 1 1 3 +2 2 1 4 +3 3 1 4 +4 4 2 4 +NULL 42 42 43 +NULL 43 42 43 + + +-- !query 58 +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id asc nulls last range between 2 preceding and 2 following) +-- !query 58 schema +struct +-- !query 58 output +1 1 1 3 +2 2 1 4 +3 3 1 4 +4 4 2 4 +NULL 42 42 43 +NULL 43 42 43 + + +-- !query 59 +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id desc nulls first range between 2 preceding and 2 following) +-- !query 59 schema +struct +-- !query 59 output +1 1 3 1 +2 2 4 1 +3 3 4 1 +4 4 4 2 +NULL 42 42 43 +NULL 43 42 43 + + +-- !query 60 +select ss.id, ss.y, + first(ss.y) over w, + last(ss.y) over w +from + (select x.id, x.id as y from range(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by ss.id desc nulls last range between 2 preceding and 2 following) +-- !query 60 schema +struct +-- !query 60 output +1 1 3 1 +2 2 4 1 +3 3 4 1 +4 4 4 2 +NULL 42 42 43 +NULL 43 42 43 + + +-- !query 61 +select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) +from range(32764, 32766) x +-- !query 61 schema +struct +-- !query 61 output +32764 32765 +32765 32765 + + +-- !query 62 +select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) +from range(-32766, -32764) x +-- !query 62 schema +struct +-- !query 62 output -32765 -32766 -32766 -32766 --- !query 47 -select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +-- !query 63 +select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x --- !query 47 schema +-- !query 63 schema struct --- !query 47 output +-- !query 63 output 2147483644 2147483645 2147483645 2147483645 --- !query 48 -select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +-- !query 64 +select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x --- !query 48 schema +-- !query 64 schema struct --- !query 48 output +-- !query 64 output -2147483645 -2147483646 -2147483646 -2147483646 --- !query 49 -select x.id, last_value(x.id) over (order by x.id range between current row and 4 following) +-- !query 65 +select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x --- !query 49 schema +-- !query 65 schema struct --- !query 49 output +-- !query 65 output 9223372036854775804 NULL 9223372036854775805 NULL --- !query 50 -select x.id, last_value(x.id) over (order by x.id desc range between current row and 5 following) +-- !query 66 +select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x --- !query 50 schema +-- !query 66 schema struct --- !query 50 output +-- !query 66 output -9223372036854775805 NULL -9223372036854775806 NULL --- !query 51 +-- !query 67 +WITH cte (x) AS ( + SELECT * FROM range(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) +-- !query 67 schema +struct +-- !query 67 output +1 4 +11 33 +13 39 +15 45 +17 51 +19 57 +21 63 +23 69 +25 75 +27 81 +29 87 +3 9 +31 93 +33 64 +5 15 +7 21 +9 27 + + +-- !query 68 +WITH cte (x) AS ( + SELECT * FROM range(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) +-- !query 68 schema +struct +-- !query 68 output +1 1 +11 11 +13 13 +15 15 +17 17 +19 19 +21 21 +23 23 +25 25 +27 27 +29 29 +3 3 +31 31 +33 33 +5 5 +7 7 +9 9 + + +-- !query 69 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM range(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) +-- !query 69 schema +struct +-- !query 69 output +1 2 +1 3 +1 7 +11 33 +13 39 +15 45 +17 51 +19 57 +21 63 +23 69 +25 75 +27 81 +29 87 +31 93 +33 99 +35 105 +37 111 +39 117 +41 123 +43 129 +45 135 +47 92 +5 13 +7 21 +9 27 + + +-- !query 70 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM range(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) +-- !query 70 schema +struct +-- !query 70 output +1 3 +1 3 +1 3 +11 11 +13 13 +15 15 +17 17 +19 19 +21 21 +23 23 +25 25 +27 27 +29 29 +31 31 +33 33 +35 35 +37 37 +39 39 +41 41 +43 43 +45 45 +47 47 +5 5 +7 7 +9 9 + + +-- !query 71 SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0 --- !query 51 schema +-- !query 71 schema struct --- !query 51 output +-- !query 71 output --- !query 52 +-- !query 72 create table t1 (f1 int, f2 int) using parquet --- !query 52 schema +-- !query 72 schema struct<> --- !query 52 output +-- !query 72 output --- !query 53 +-- !query 73 insert into t1 values (1,1),(1,2),(2,2) --- !query 53 schema +-- !query 73 schema struct<> --- !query 53 output +-- !query 73 output --- !query 54 +-- !query 74 +select f1, sum(f1) over (partition by f1, f1 order by f2 +range between 2 preceding and 1 preceding) +from t1 where f1 = f2 +-- !query 74 schema +struct +-- !query 74 output +1 NULL +2 NULL + + +-- !query 75 +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) +from t1 where f1 = f2 +-- !query 75 schema +struct +-- !query 75 output +1 NULL +2 NULL + + +-- !query 76 SELECT rank() OVER (ORDER BY length('abc')) --- !query 54 schema +-- !query 76 schema struct --- !query 54 output +-- !query 76 output 1 --- !query 55 +-- !query 77 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 55 schema +-- !query 77 schema struct --- !query 55 output +-- !query 77 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 56 +-- !query 78 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 56 schema +-- !query 78 schema struct --- !query 56 output +-- !query 78 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 57 +-- !query 79 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 57 schema +-- !query 79 schema struct --- !query 57 output +-- !query 79 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 58 +-- !query 80 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 58 schema +-- !query 80 schema struct --- !query 58 output +-- !query 80 output 1 2 2 2.5 3 NULL 4 NULL --- !query 59 +-- !query 81 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 59 schema +-- !query 81 schema struct --- !query 59 output +-- !query 81 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 60 +-- !query 82 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 60 schema +-- !query 82 schema struct --- !query 60 output +-- !query 82 output 1 3 2 2 3 NULL 4 NULL --- !query 61 +-- !query 83 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 61 schema +-- !query 83 schema struct --- !query 61 output +-- !query 83 output 1 3 2 2 3 NULL 4 NULL --- !query 62 +-- !query 84 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 62 schema +-- !query 84 schema struct --- !query 62 output +-- !query 84 output 1 3 2 2 3 NULL 4 NULL --- !query 63 +-- !query 85 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 63 schema +-- !query 85 schema struct --- !query 63 output +-- !query 85 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 64 +-- !query 86 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 64 schema +-- !query 86 schema struct --- !query 64 output +-- !query 86 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 65 +-- !query 87 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 65 schema +-- !query 87 schema struct --- !query 65 output +-- !query 87 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 66 +-- !query 88 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 66 schema +-- !query 88 schema struct --- !query 66 output +-- !query 88 output 3 5 6.01 --- !query 67 +-- !query 89 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 67 schema +-- !query 89 schema struct --- !query 67 output +-- !query 89 output 1 2 2 1 3 0 4 0 --- !query 68 +-- !query 90 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 68 schema +-- !query 90 schema struct --- !query 68 output +-- !query 90 output 1 4 2 3 3 2 4 1 --- !query 69 +-- !query 91 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 69 schema +-- !query 91 schema struct --- !query 69 output +-- !query 91 output 0.0 11266.666666666666 13868.750000000002 @@ -1100,12 +1523,12 @@ struct --- !query 70 output +-- !query 92 output 0.0 11266.666666666666 13868.750000000002 @@ -1113,12 +1536,12 @@ struct --- !query 71 output +-- !query 93 output 0.0 11266.666666666666 13868.750000000002 @@ -1126,12 +1549,12 @@ struct --- !query 72 output +-- !query 94 output 0.0 11266.666666666666 13868.750000000002 @@ -1139,12 +1562,12 @@ struct --- !query 73 output +-- !query 95 output 16900.0 18491.666666666668 27129.999999999996 @@ -1152,12 +1575,12 @@ struct --- !query 74 output +-- !query 96 output 16900.0 18491.666666666668 27129.999999999996 @@ -1165,12 +1588,12 @@ struct --- !query 75 output +-- !query 97 output 16900.0 18491.666666666668 27129.999999999996 @@ -1178,12 +1601,12 @@ struct --- !query 76 output +-- !query 98 output 16900.0 18491.666666666668 27129.999999999996 @@ -1191,12 +1614,12 @@ struct --- !query 77 output +-- !query 99 output 16900.0 18491.666666666668 27129.999999999996 @@ -1204,12 +1627,12 @@ struct --- !query 78 output +-- !query 100 output 16900.0 18491.666666666668 27129.999999999996 @@ -1217,12 +1640,12 @@ struct --- !query 79 output +-- !query 101 output 16900.0 18491.666666666668 27129.999999999996 @@ -1230,12 +1653,12 @@ struct --- !query 80 output +-- !query 102 output 16900.0 18491.666666666668 27129.999999999996 @@ -1243,12 +1666,12 @@ struct --- !query 81 output +-- !query 103 output 0.0 106.14455552060438 117.76565713313879 @@ -1257,12 +1680,12 @@ struct --- !query 82 output +-- !query 104 output 0.0 106.14455552060438 117.76565713313879 @@ -1271,12 +1694,12 @@ struct --- !query 83 output +-- !query 105 output 0.0 106.14455552060438 117.76565713313879 @@ -1285,12 +1708,12 @@ struct --- !query 84 output +-- !query 106 output 0.0 106.14455552060438 117.76565713313879 @@ -1299,12 +1722,12 @@ struct --- !query 85 output +-- !query 107 output 130.0 135.9840676942217 164.7118696390761 @@ -1313,12 +1736,12 @@ struct --- !query 86 output +-- !query 108 output 130.0 135.9840676942217 164.7118696390761 @@ -1327,12 +1750,12 @@ struct --- !query 87 output +-- !query 109 output 130.0 135.9840676942217 164.7118696390761 @@ -1341,12 +1764,12 @@ struct --- !query 88 output +-- !query 110 output 130.0 135.9840676942217 164.7118696390761 @@ -1355,12 +1778,12 @@ struct --- !query 89 output +-- !query 111 output 130.0 135.9840676942217 164.7118696390761 @@ -1369,12 +1792,12 @@ struct --- !query 90 output +-- !query 112 output 130.0 135.9840676942217 164.7118696390761 @@ -1383,12 +1806,12 @@ struct --- !query 91 output +-- !query 113 output 130.0 135.9840676942217 164.7118696390761 @@ -1397,12 +1820,12 @@ struct --- !query 92 output +-- !query 114 output 130.0 135.9840676942217 164.7118696390761 @@ -1411,61 +1834,61 @@ struct --- !query 93 output +-- !query 115 output 1 1 2 2 3 NULL 4 NULL --- !query 94 +-- !query 116 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 94 schema +-- !query 116 schema struct --- !query 94 output +-- !query 116 output 1 3 2 2 3 NULL 4 NULL --- !query 95 +-- !query 117 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 95 schema +-- !query 117 schema struct --- !query 95 output +-- !query 117 output 1 3 2 6 3 9 4 7 --- !query 96 +-- !query 118 drop table empsalary --- !query 96 schema +-- !query 118 schema struct<> --- !query 96 output +-- !query 118 output --- !query 97 +-- !query 119 drop table t1 --- !query 97 schema +-- !query 119 schema struct<> --- !query 97 output +-- !query 119 output --- !query 98 +-- !query 120 drop view int4_tbl --- !query 98 schema +-- !query 120 schema struct<> --- !query 98 output +-- !query 120 output From 11e2373be542042ef4ad108b4c7cc435c569df18 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 17 Jul 2019 10:51:08 -0300 Subject: [PATCH 09/25] remove additiona 'e' char Signed-off-by: DylanGuedes --- .../src/test/resources/sql-tests/inputs/pgSQL/window.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 1a40e74396342..69fe08486e2d9 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -251,17 +251,17 @@ FROM tenk1 WHERE unique1 < 10; -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- mismatched input '(' e +-- mismatched input '(' -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- mismatched input '(' e +-- mismatched input '(' -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- mismatched input '(' e +-- mismatched input '(' -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); From e8ace71f3a9ad2d7a35664d60d569e7677518b19 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Wed, 17 Jul 2019 09:02:37 -0700 Subject: [PATCH 10/25] fix --- .../sql-tests/inputs/pgSQL/window.sql | 4 +- .../sql-tests/results/pgSQL/window.sql.out | 668 +++++++++--------- .../sql-tests/results/show-tables.sql.out | 2 - .../apache/spark/sql/SQLQueryTestSuite.scala | 26 - 4 files changed, 341 insertions(+), 359 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 69fe08486e2d9..e107b31629708 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -1,7 +1,9 @@ -- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group -- -- Window Functions Testing --- https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/window.sql +-- https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/sql/window.sql + +CREATE TEMPORARY VIEW tenk2 AS SELECT * FROM tenk1; CREATE TABLE empsalary ( depname string, diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index e6dcaf7b08cf6..e6d48a69095aa 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,21 +1,29 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 121 +-- Number of queries: 122 -- !query 0 +CREATE TEMPORARY VIEW tenk2 AS SELECT * FROM tenk1 +-- !query 0 schema +struct<> +-- !query 0 output + + + +-- !query 1 CREATE TABLE empsalary ( depname string, empno integer, salary int, enroll_date date ) USING parquet --- !query 0 schema +-- !query 1 schema struct<> --- !query 0 output +-- !query 1 output --- !query 1 +-- !query 2 INSERT INTO empsalary VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), @@ -27,17 +35,17 @@ INSERT INTO empsalary VALUES ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15') --- !query 1 schema +-- !query 2 schema struct<> --- !query 1 output +-- !query 2 output --- !query 2 +-- !query 3 SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname) FROM empsalary ORDER BY depname, salary --- !query 2 schema +-- !query 3 schema struct --- !query 2 output +-- !query 3 output develop 7 4200 25100 develop 9 4500 25100 develop 10 5200 25100 @@ -50,11 +58,11 @@ sales 3 4800 14600 sales 1 5000 14600 --- !query 3 +-- !query 4 SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary --- !query 3 schema +-- !query 4 schema struct --- !query 3 output +-- !query 4 output develop 10 5200 3 develop 11 5200 3 develop 7 4200 1 @@ -67,12 +75,12 @@ sales 3 4800 1 sales 4 4800 1 --- !query 4 +-- !query 5 SELECT four, ten, SUM(SUM(four)) OVER (PARTITION BY four), AVG(ten) FROM tenk1 GROUP BY four, ten ORDER BY four, ten --- !query 4 schema +-- !query 5 schema struct --- !query 4 output +-- !query 5 output 0 0 0 0.0 0 2 0 2.0 0 4 0 4.0 @@ -95,11 +103,11 @@ struct --- !query 5 output +-- !query 6 output develop 10 5200 25100 develop 11 5200 25100 develop 7 4200 25100 @@ -112,11 +120,11 @@ sales 3 4800 14600 sales 4 4800 14600 --- !query 6 +-- !query 7 SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10 --- !query 6 schema +-- !query 7 schema struct --- !query 6 output +-- !query 7 output 10 10 10 @@ -129,11 +137,11 @@ struct --- !query 7 output +-- !query 8 output 10 10 10 @@ -146,19 +154,19 @@ struct --- !query 8 output +-- !query 9 output --- !query 9 +-- !query 10 SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10 --- !query 9 schema +-- !query 10 schema struct --- !query 9 output +-- !query 10 output 0 0 0 0 0 0 0 4 0 @@ -171,11 +179,11 @@ struct 5 1 1 --- !query 10 +-- !query 11 SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10 --- !query 10 schema +-- !query 11 schema struct --- !query 10 output +-- !query 11 output 1 10 2 @@ -188,11 +196,11 @@ struct --- !query 11 output +-- !query 12 output 1 0 0 1 0 0 1 0 2 @@ -205,11 +213,11 @@ struct 4 9 1 --- !query 12 +-- !query 13 SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 12 schema +-- !query 13 schema struct --- !query 12 output +-- !query 13 output 1 0 0 1 0 0 1 0 2 @@ -222,11 +230,11 @@ struct --- !query 13 output +-- !query 14 output 0.0 0 0 0.0 0 0 0.0 0 2 @@ -239,11 +247,11 @@ struct --- !query 14 output +-- !query 15 output 0.5 1 1 0.5 1 1 0.5 1 3 @@ -256,11 +264,11 @@ struct --- !query 15 output +-- !query 16 output 1 0 0 1 0 0 1 0 2 @@ -273,11 +281,11 @@ struct --- !query 16 output +-- !query 17 output 0 0 0 0 4 0 1 1 1 @@ -290,11 +298,11 @@ NULL 1 1 NULL 1 3 --- !query 17 +-- !query 18 SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 17 schema +-- !query 18 schema struct --- !query 17 output +-- !query 18 output 0 0 0 1 1 1 3 1 3 @@ -307,11 +315,11 @@ NULL 4 0 NULL 9 1 --- !query 18 +-- !query 19 SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 18 schema +-- !query 19 schema struct --- !query 18 output +-- !query 19 output 0 0 0 14 1 1 18 7 1 @@ -324,11 +332,11 @@ NULL 4 0 NULL 9 1 --- !query 19 +-- !query 20 SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 --- !query 19 schema +-- !query 20 schema struct --- !query 19 output +-- !query 20 output -1 0 2 -1 3 3 -1 4 0 @@ -341,11 +349,11 @@ struct --- !query 20 output +-- !query 21 output 0 0 0 0 0 0 0 0 2 @@ -358,11 +366,11 @@ struct --- !query 21 output +-- !query 22 output 0 4 0 1 1 1 1 1 1 @@ -375,13 +383,13 @@ struct --- !query 22 output +-- !query 23 output 4 0 0 4 0 0 4 4 0 @@ -394,12 +402,12 @@ struct --- !query 23 output +-- !query 24 output 0 0 45000 45000 1 1 46000 46000 2 0 47000 92000 @@ -412,11 +420,11 @@ struct 9 1 54000 250000 --- !query 24 +-- !query 25 SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10 --- !query 24 schema +-- !query 25 schema struct --- !query 24 output +-- !query 25 output 2 3 2 3 4 1 @@ -425,13 +433,13 @@ struct --- !query 25 output +-- !query 26 output 136 22 22 @@ -444,7 +452,7 @@ struct 92 --- !query 26 +-- !query 27 SELECT * FROM( SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, @@ -452,17 +460,17 @@ SELECT * FROM( sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS twosum FROM tenk1 )sub WHERE total <> fourcount + twosum --- !query 26 schema +-- !query 27 schema struct --- !query 26 output +-- !query 27 output --- !query 27 +-- !query 28 SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10 --- !query 27 schema +-- !query 28 schema struct --- !query 27 output +-- !query 28 output 0.0 0.0 0.0 @@ -475,12 +483,12 @@ struct --- !query 28 output +-- !query 29 output 0 0 45000 45000 1 1 46000 46000 2 0 47000 92000 @@ -493,25 +501,25 @@ struct 9 1 54000 250000 --- !query 29 +-- !query 30 SELECT sum(salary), row_number() OVER (ORDER BY depname), sum(sum(salary)) OVER (ORDER BY depname DESC) FROM empsalary GROUP BY depname --- !query 29 schema +-- !query 30 schema struct --- !query 29 output +-- !query 30 output 14600 3 14600 25100 1 47100 7400 2 22000 --- !query 30 +-- !query 31 SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary) --- !query 30 schema +-- !query 31 schema struct --- !query 30 output +-- !query 31 output 11600 3 16100 4 25700 6 @@ -524,19 +532,19 @@ struct --- !query 31 output +-- !query 32 output --- !query 32 +-- !query 33 SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) --- !query 32 schema +-- !query 33 schema struct --- !query 32 output +-- !query 33 output 14600 2 14600 2 16400 2 @@ -549,7 +557,7 @@ struct --- !query 33 output +-- !query 34 output --- !query 34 +-- !query 35 SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 --- !query 34 schema +-- !query 35 schema struct --- !query 34 output +-- !query 35 output 0 --- !query 35 +-- !query 36 select ten, sum(unique1) + sum(unique2) as res, rank() over (order by sum(unique1) + sum(unique2)) as rank from tenk1 group by ten order by ten --- !query 35 schema +-- !query 36 schema struct --- !query 35 output +-- !query 36 output 0 9976146 4 1 10114187 9 2 10059554 8 @@ -592,13 +600,13 @@ struct 9 10040184 7 --- !query 36 +-- !query 37 select first(max(x)) over (), y from (select unique1 as x, ten+four as y from tenk1) ss group by y --- !query 36 schema +-- !query 37 schema struct --- !query 36 output +-- !query 37 output 9980 0 9980 10 9980 12 @@ -608,14 +616,14 @@ struct --- !query 37 output +-- !query 38 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -638,14 +646,14 @@ struct --- !query 38 output +-- !query 39 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -668,14 +676,14 @@ struct --- !query 39 output +-- !query 40 output 0 0 20 8 0 2 20 8 0 4 20 8 @@ -698,14 +706,14 @@ struct --- !query 40 output +-- !query 41 output 0 0 0 0 0 0 0 0 0 1 2 1 @@ -728,14 +736,14 @@ struct --- !query 41 output +-- !query 42 output 0 0 0 0 0 0 0 0 0 1 1 1 @@ -758,13 +766,13 @@ struct --- !query 42 output +-- !query 43 output 10 3 3 10 7 3 18 2 2 @@ -777,13 +785,13 @@ struct --- !query 43 output +-- !query 44 output 0 0 0 10 3 3 15 5 1 @@ -796,13 +804,13 @@ struct --- !query 44 output +-- !query 45 output 10 0 0 13 2 2 15 7 3 @@ -815,13 +823,13 @@ struct --- !query 45 output +-- !query 46 output 10 0 0 13 3 3 15 8 0 @@ -834,13 +842,13 @@ struct --- !query 46 output +-- !query 47 output 0 7 3 10 5 1 15 8 0 @@ -853,13 +861,13 @@ struct --- !query 47 output +-- !query 48 output 13 1 1 22 6 2 30 9 1 @@ -872,21 +880,21 @@ struct --- !query 48 output +-- !query 49 output --- !query 49 +-- !query 50 SELECT * FROM v_window --- !query 49 schema +-- !query 50 schema struct --- !query 49 output +-- !query 50 output 1 3 2 6 3 9 @@ -898,11 +906,11 @@ struct 9 17 --- !query 50 +-- !query 51 SELECT * FROM v_window --- !query 50 schema +-- !query 51 schema struct --- !query 50 output +-- !query 51 output 1 3 2 6 3 9 @@ -914,11 +922,11 @@ struct 9 17 --- !query 51 +-- !query 52 SELECT * FROM v_window --- !query 51 schema +-- !query 52 schema struct --- !query 51 output +-- !query 52 output 1 3 2 6 3 9 @@ -930,11 +938,11 @@ struct 9 17 --- !query 52 +-- !query 53 SELECT * FROM v_window --- !query 52 schema +-- !query 53 schema struct --- !query 52 output +-- !query 53 output 1 3 2 6 3 9 @@ -946,21 +954,21 @@ struct 9 17 --- !query 53 +-- !query 54 DROP VIEW v_window --- !query 53 schema +-- !query 54 schema struct<> --- !query 53 output +-- !query 54 output --- !query 54 +-- !query 55 SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 54 schema +-- !query 55 schema struct --- !query 54 output +-- !query 55 output 12 1 1 12 5 1 12 9 1 @@ -973,13 +981,13 @@ NULL 4 0 NULL 8 0 --- !query 55 +-- !query 56 SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 55 schema +-- !query 56 schema struct --- !query 55 output +-- !query 56 output 10 2 2 10 6 2 18 1 1 @@ -992,13 +1000,13 @@ NULL 3 3 NULL 7 3 --- !query 56 +-- !query 57 SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 56 schema +-- !query 57 schema struct --- !query 56 output +-- !query 57 output 10 3 3 10 7 3 12 4 0 @@ -1011,7 +1019,7 @@ struct --- !query 57 output +-- !query 58 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1032,7 +1040,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 58 +-- !query 59 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1042,9 +1050,9 @@ from union all select null, 43) ss window w as (order by ss.id asc nulls last range between 2 preceding and 2 following) --- !query 58 schema +-- !query 59 schema struct --- !query 58 output +-- !query 59 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1053,7 +1061,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 59 +-- !query 60 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1063,9 +1071,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls first range between 2 preceding and 2 following) --- !query 59 schema +-- !query 60 schema struct --- !query 59 output +-- !query 60 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1074,7 +1082,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 60 +-- !query 61 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1084,9 +1092,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls last range between 2 preceding and 2 following) --- !query 60 schema +-- !query 61 schema struct --- !query 60 output +-- !query 61 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1095,76 +1103,76 @@ NULL 42 42 43 NULL 43 42 43 --- !query 61 +-- !query 62 select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) from range(32764, 32766) x --- !query 61 schema +-- !query 62 schema struct --- !query 61 output +-- !query 62 output 32764 32765 32765 32765 --- !query 62 +-- !query 63 select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) from range(-32766, -32764) x --- !query 62 schema +-- !query 63 schema struct --- !query 62 output +-- !query 63 output -32765 -32766 -32766 -32766 --- !query 63 +-- !query 64 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x --- !query 63 schema +-- !query 64 schema struct --- !query 63 output +-- !query 64 output 2147483644 2147483645 2147483645 2147483645 --- !query 64 +-- !query 65 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x --- !query 64 schema +-- !query 65 schema struct --- !query 64 output +-- !query 65 output -2147483645 -2147483646 -2147483646 -2147483646 --- !query 65 +-- !query 66 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x --- !query 65 schema +-- !query 66 schema struct --- !query 65 output +-- !query 66 output 9223372036854775804 NULL 9223372036854775805 NULL --- !query 66 +-- !query 67 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x --- !query 66 schema +-- !query 67 schema struct --- !query 66 output +-- !query 67 output -9223372036854775805 NULL -9223372036854775806 NULL --- !query 67 +-- !query 68 WITH cte (x) AS ( SELECT * FROM range(1, 35, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) --- !query 67 schema +-- !query 68 schema struct --- !query 67 output +-- !query 68 output 1 4 11 33 13 39 @@ -1184,16 +1192,16 @@ struct --- !query 68 output +-- !query 69 output 1 1 11 11 13 13 @@ -1213,7 +1221,7 @@ struct --- !query 69 output +-- !query 70 output 1 2 1 3 1 7 @@ -1251,7 +1259,7 @@ struct --- !query 70 output +-- !query 71 output 1 3 1 3 1 3 @@ -1289,24 +1297,16 @@ struct --- !query 71 output - - - -- !query 72 -create table t1 (f1 int, f2 int) using parquet +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0 -- !query 72 schema -struct<> +struct -- !query 72 output -- !query 73 -insert into t1 values (1,1),(1,2),(2,2) +create table t1 (f1 int, f2 int) using parquet -- !query 73 schema struct<> -- !query 73 output @@ -1314,45 +1314,41 @@ struct<> -- !query 74 -select f1, sum(f1) over (partition by f1, f1 order by f2 -range between 2 preceding and 1 preceding) -from t1 where f1 = f2 +insert into t1 values (1,1),(1,2),(2,2) -- !query 74 schema -struct +struct<> -- !query 74 output -1 NULL -2 NULL + -- !query 75 -select f1, sum(f1) over (partition by f1, f2 order by f2 -range between 1 following and 2 following) +select f1, sum(f1) over (partition by f1, f1 order by f2 +range between 2 preceding and 1 preceding) from t1 where f1 = f2 -- !query 75 schema -struct +struct -- !query 75 output 1 NULL 2 NULL -- !query 76 -SELECT rank() OVER (ORDER BY length('abc')) +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) +from t1 where f1 = f2 -- !query 76 schema -struct +struct -- !query 76 output -1 +1 NULL +2 NULL -- !query 77 -SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +SELECT rank() OVER (ORDER BY length('abc')) -- !query 77 schema -struct +struct -- !query 77 output -1 1.5 -2 2.0 -3 NULL -4 NULL +1 -- !query 78 @@ -1381,36 +1377,36 @@ struct +struct -- !query 80 output -1 2 -2 2.5 +1 1.5 +2 2.0 3 NULL 4 NULL -- !query 81 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) -- !query 81 schema -struct +struct -- !query 81 output -1 NULL -2 NULL +1 2 +2 2.5 3 NULL 4 NULL -- !query 82 -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) -- !query 82 schema -struct +struct -- !query 82 output -1 3 -2 2 +1 NULL +2 NULL 3 NULL 4 NULL @@ -1441,88 +1437,87 @@ struct +struct -- !query 85 output -1 3.3000000000000003 -2 2.2 +1 3 +2 2 3 NULL 4 NULL -- !query 86 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) -- !query 86 schema struct -- !query 86 output +1 3.3000000000000003 +2 2.2 +3 NULL +4 NULL + + +-- !query 87 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- !query 87 schema +struct +-- !query 87 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 87 +-- !query 88 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 87 schema +-- !query 88 schema struct --- !query 87 output +-- !query 88 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 88 +-- !query 89 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 88 schema +-- !query 89 schema struct --- !query 88 output +-- !query 89 output 3 5 6.01 --- !query 89 +-- !query 90 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 89 schema +-- !query 90 schema struct --- !query 89 output +-- !query 90 output 1 2 2 1 3 0 4 0 --- !query 90 +-- !query 91 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 90 schema +-- !query 91 schema struct --- !query 90 output +-- !query 91 output 1 4 2 3 3 2 4 1 --- !query 91 -SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 91 schema -struct --- !query 91 output -0.0 -11266.666666666666 -13868.750000000002 -21703.999999999996 -4225.0 - - -- !query 92 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) @@ -1563,16 +1558,16 @@ struct +struct -- !query 95 output -16900.0 -18491.666666666668 -27129.999999999996 -8450.0 -NaN +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 -- !query 96 @@ -1615,7 +1610,7 @@ NaN -- !query 99 -SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 99 schema struct @@ -1667,17 +1662,16 @@ NaN -- !query 103 -SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 103 schema -struct +struct -- !query 103 output -0.0 -106.14455552060438 -117.76565713313879 -147.32277488562315 -147.32277488562315 -65.0 +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN -- !query 104 @@ -1723,17 +1717,17 @@ struct +struct -- !query 107 output -130.0 -135.9840676942217 -164.7118696390761 -164.7118696390761 -91.92388155425118 -NaN +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 -- !query 108 @@ -1779,8 +1773,8 @@ NaN -- !query 111 -SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) -- !query 111 schema struct -- !query 111 output @@ -1835,60 +1829,74 @@ NaN -- !query 115 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 115 schema +struct +-- !query 115 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 116 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 115 schema +-- !query 116 schema struct --- !query 115 output +-- !query 116 output 1 1 2 2 3 NULL 4 NULL --- !query 116 +-- !query 117 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 116 schema +-- !query 117 schema struct --- !query 116 output +-- !query 117 output 1 3 2 2 3 NULL 4 NULL --- !query 117 +-- !query 118 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 117 schema +-- !query 118 schema struct --- !query 117 output +-- !query 118 output 1 3 2 6 3 9 4 7 --- !query 118 +-- !query 119 drop table empsalary --- !query 118 schema +-- !query 119 schema struct<> --- !query 118 output +-- !query 119 output --- !query 119 +-- !query 120 drop table t1 --- !query 119 schema +-- !query 120 schema struct<> --- !query 119 output +-- !query 120 output --- !query 120 +-- !query 121 drop view int4_tbl --- !query 120 schema +-- !query 121 schema struct<> --- !query 120 output +-- !query 121 output diff --git a/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out b/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out index 56e781ac02d2e..f22cb7e200e6c 100644 --- a/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/show-tables.sql.out @@ -71,7 +71,6 @@ show_t1 show_t2 show_t3 tenk1 -tenk2 testdata @@ -88,7 +87,6 @@ show_t1 show_t2 show_t3 tenk1 -tenk2 testdata diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala index bb3088ac262ea..4bdf25051127c 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala @@ -529,32 +529,6 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext { """.stripMargin) .load(testFile("test-data/postgresql/tenk.data")) .createOrReplaceTempView("tenk1") - - session - .read - .format("csv") - .options(Map("delimiter" -> "\t", "header" -> "false")) - .schema( - """ - |unique1 int, - |unique2 int, - |two int, - |four int, - |ten int, - |twenty int, - |hundred int, - |thousand int, - |twothousand int, - |fivethous int, - |tenthous int, - |odd int, - |even int, - |stringu1 string, - |stringu2 string, - |string4 string - """.stripMargin) - .load(testFile("test-data/postgresql/tenk.data")) - .createOrReplaceTempView("tenk2") } private val originalTimeZone = TimeZone.getDefault From e1ff740ce08d86eb46d6d1c0ad185c6b41d0d6d1 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Tue, 23 Jul 2019 09:03:15 -0300 Subject: [PATCH 11/25] update with new jiras Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 304 ++++--- .../sql-tests/results/pgSQL/window.sql.out | 791 +++++++++++++----- 2 files changed, 729 insertions(+), 366 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index e107b31629708..407e6d5b944de 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -187,51 +187,52 @@ SELECT sum(unique1) over (rows between 2 preceding and 2 following), unique1, four FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT first(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT first(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT first(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT last(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT last(unique1) over (ORDER BY four rows between current row and 2 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT last(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; @@ -248,22 +249,22 @@ SELECT sum(unique1) over (rows between unbounded preceding and 1 following), unique1, four FROM tenk1 WHERE unique1 < 10; ---mismatched input '(' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (w range between current row and unbounded following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- mismatched input '(' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- mismatched input '(' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); --- mismatched input '(' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); @@ -288,41 +289,40 @@ FROM range(1, 10) i; SELECT * FROM v_window; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude current row) as sum_rows FROM range(1, 10) i; SELECT * FROM v_window; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude group) as sum_rows FROM range(1, 10) i; SELECT * FROM v_window; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude ties) as sum_rows FROM generate_series(1, 10) i; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude no others) as sum_rows FROM generate_series(1, 10) i; SELECT * FROM v_window; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- CREATE OR REPLACE TEMP VIEW v_window AS --- SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i; --- --- SELECT * FROM v_window; +CREATE OR REPLACE TEMP VIEW v_window AS +SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i; + +SELECT * FROM v_window; DROP VIEW v_window; --- cannot resolve '(current_timestamp() + CAST('100 days' AS DOUBLE))' due to data type mismatch: differing types in '(current_timestamp() + CAST('100 days' AS DOUBLE))' (timestamp and double).; +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp -- CREATE TEMP VIEW v_window AS -- SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i -- FROM range(now(), now()+'100 days', '1 hour') i; @@ -335,32 +335,32 @@ SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 pre unique1, four FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude no others), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude current row), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (order by four range between 2 preceding and 6 following exclude ties), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (order by four range between 2 preceding and 6 following exclude group), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; @@ -369,32 +369,32 @@ SELECT sum(unique1) over (partition by four order by unique1 range between 5 pre unique1, four FROM tenk1 WHERE unique1 < 10; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following -- exclude current row),unique1, four -- FROM tenk1 WHERE unique1 < 10; --- cannot resolve 'RANGE BETWEEN CAST('1 year' AS DOUBLE) PRECEDING AND '1 year' FOLLOWING' due to data type mismatch: The data type of the upper bound 'string' does not match the expected data type '(numeric or calendarinterval)'.; +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp -- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following), -- salary, enroll_date from empsalary; --- cannot resolve 'RANGE BETWEEN CAST('1 year' AS DOUBLE) PRECEDING AND '1 year' FOLLOWING' due to data type mismatch: The data type of the upper bound 'string' does not match the expected data type '(numeric or calendarinterval)'.; +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp -- select sum(salary) over (order by enroll_date desc range between '1 year' preceding and '1 year' following), -- salary, enroll_date from empsalary; --- cannot resolve 'RANGE BETWEEN '1 year' FOLLOWING AND '1 year' FOLLOWING' due to data type mismatch: The data type of the lower bound 'string' does not match the expected data type '(numeric or calendarinterval)'.; +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp -- select sum(salary) over (order by enroll_date desc range between '1 year' following and '1 year' following), -- salary, enroll_date from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following -- exclude current row), salary, enroll_date from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following -- exclude group), salary, enroll_date from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select sum(salary) over (order by enroll_date range between '1 year' preceding and '1 year' following -- exclude ties), salary, enroll_date from empsalary; @@ -417,40 +417,39 @@ FROM tenk1 WHERE unique1 < 10; -- exclude ties), -- salary from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select last(salary) over(order by salary range between 1000 following and 3000 following -- exclude group), -- lag(salary) over(order by salary range between 1000 following and 3000 following exclude group), -- salary from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude ties), -- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following), -- salary, enroll_date from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude ties), -- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude ties), -- salary, enroll_date from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude group), -- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude group), -- salary, enroll_date from empsalary; --- missing ')' at 'exclude' +-- [SPARK-28428] Spark `exclude` always expecting `()` -- select first(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude current row), -- last(salary) over(order by enroll_date range between unbounded preceding and '1 year' following -- exclude current row), -- salary, enroll_date from empsalary; --- in Spark, x is ambiguous for the following queries select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -509,84 +508,75 @@ from range(9223372036854775804, 9223372036854775806) x; select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between unbounded preceding and current row), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between unbounded preceding and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between current row and unbounded following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between 1 preceding and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between 1 following and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), +unique1, four +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 following -- exclude current row), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 following -- exclude group), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- SELECT sum(unique1) over (order by four range between 2 preceding and 1 following -- exclude ties), unique1, four -- FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- SELECT sum(unique1) over (partition by ten --- order by four groups between 0 preceding and 0 following),unique1, four, ten --- FROM tenk1 WHERE unique1 < 10; +SELECT sum(unique1) over (partition by ten + order by four range between 0 preceding and 0 following),unique1, four, ten +FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (partition by ten --- order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten +-- order by four range between 0 preceding and 0 following exclude current row), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (partition by ten --- order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten +-- order by four range between 0 preceding and 0 following exclude group), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} +-- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (partition by ten --- order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten +-- order by four range between 0 preceding and 0 following exclude ties), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; -- [SPARK-27951] ANSI SQL: NTH_VALUE function @@ -595,9 +585,9 @@ from range(-9223372036854775806, -9223372036854775804) x; -- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- select last(salary) over(order by enroll_date groups between 1 preceding and 1 following), --- lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- Window Frame specifiedwindowframe(RangeFrame, -1, 1) must match the required frame specifiedwindowframe(RowFrame, -1, -1); +-- select last(salary) over(order by enroll_date range between 1 preceding and 1 following), +-- lag(salary) over(order by enroll_date range between 1 preceding and 1 following), -- salary, enroll_date from empsalary; -- [SPARK-27951] ANSI SQL: NTH_VALUE function @@ -608,10 +598,10 @@ from range(-9223372036854775806, -9223372036854775804) x; -- exclude ties), -- salary, enroll_date from empsalary; --- mismatched input 'groups' expecting {')', ',', 'RANGE', 'ROWS'} --- select last(salary) over(order by enroll_date groups between 1 following and 3 following +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select last(salary) over(order by enroll_date range between 1 following and 3 following -- exclude group), --- lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), +-- lag(salary) over(order by enroll_date range between 1 following and 3 following exclude group), -- salary, enroll_date from empsalary; WITH cte (x) AS ( @@ -666,18 +656,17 @@ SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SEL create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); --- broken - costs not available --- select f1, sum(f1) over (partition by f1 --- range between 1 preceding and 1 following) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1 + range between 1 preceding and 1 following) +from t1 where f1 = f2; --- explain (costs off) --- select f1, sum(f1) over (partition by f1 order by f2 --- range between 1 preceding and 1 following) --- from t1 where f1 = f2; --- select f1, sum(f1) over (partition by f1 order by f2 --- range between 1 preceding and 1 following) --- from t1 where f1 = f2; +explain +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1 order by f2 + range between 1 preceding and 1 following) +from t1 where f1 = f2; select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) @@ -687,31 +676,27 @@ select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2; --- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} +-- cannot resolve '(PARTITION BY default.t1.`f1` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)' due to data type mismatch: A range window frame cannot be used in an unordered window specification. -- select f1, sum(f1) over (partition by f1 --- groups between 1 preceding and 1 following) +-- range between 1 preceding and 1 following) -- from t1 where f1 = f2; --- explain(costs off) not available --- explain (costs off) --- select f1, sum(f1) over (partition by f1 order by f2 --- groups between 1 preceding and 1 following) --- from t1 where f1 = f2; +explain +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2; --- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} --- select f1, sum(f1) over (partition by f1 order by f2 --- groups between 1 preceding and 1 following) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2; --- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} --- select f1, sum(f1) over (partition by f1, f1 order by f2 --- groups between 2 preceding and 1 preceding) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1, f1 order by f2 +range between 2 preceding and 1 preceding) +from t1 where f1 = f2; --- mismatched input 'groups' expecting {')', ',', 'ORDER', 'RANGE', 'ROWS', 'SORT'} --- select f1, sum(f1) over (partition by f1, f2 order by f2 --- groups between 1 following and 2 following) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) +from t1 where f1 = f2; SELECT rank() OVER (ORDER BY length('abc')); @@ -759,39 +744,35 @@ SELECT rank() OVER (ORDER BY length('abc')); -- depname -- FROM empsalary GROUP BY depname; --- explain (costs off) not available --- EXPLAIN (COSTS OFF) --- SELECT * FROM --- (SELECT depname, --- sum(salary) OVER (PARTITION BY depname) depsalary, --- min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary --- FROM empsalary) emp --- WHERE depname = 'sales'; - --- explain (costs off) not available --- EXPLAIN (COSTS OFF) --- SELECT * FROM --- (SELECT depname, --- sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, --- min(salary) OVER (PARTITION BY depname) depminsalary --- FROM empsalary) emp --- WHERE depname = 'sales'; - --- explain (costs off) not available --- EXPLAIN (COSTS OFF) --- SELECT * FROM --- (SELECT depname, --- sum(salary) OVER (PARTITION BY depname order by empno) depsalary, --- min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary --- FROM empsalary) emp --- WHERE depname = 'sales'; - --- explain (costs off) not available --- EXPLAIN (COSTS OFF) --- SELECT --- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), --- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) --- FROM empsalary; +EXPLAIN +SELECT * FROM +(SELECT depname, +sum(salary) OVER (PARTITION BY depname) depsalary, +min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary +FROM empsalary) emp +WHERE depname = 'sales'; + +EXPLAIN +SELECT * FROM +(SELECT depname, +sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, +min(salary) OVER (PARTITION BY depname) depminsalary +FROM empsalary) emp +WHERE depname = 'sales'; + +EXPLAIN +SELECT * FROM +(SELECT depname, +sum(salary) OVER (PARTITION BY depname order by empno) depsalary, +min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary +FROM empsalary) emp +WHERE depname = 'sales'; + +EXPLAIN +SELECT +lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), +lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +FROM empsalary; SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); @@ -921,7 +902,6 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) -- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) -- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); --- cleanup drop table empsalary; drop table t1; drop view int4_tbl; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index e6d48a69095aa..7c8104824851e 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 122 +-- Number of queries: 144 -- !query 0 @@ -955,7 +955,8 @@ struct -- !query 54 -DROP VIEW v_window +CREATE OR REPLACE TEMP VIEW v_window AS +SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i -- !query 54 schema struct<> -- !query 54 output @@ -963,12 +964,36 @@ struct<> -- !query 55 +SELECT * FROM v_window +-- !query 55 schema +struct +-- !query 55 output +1 3 +2 6 +3 9 +4 12 +5 15 +6 18 +7 21 +8 24 +9 17 + + +-- !query 56 +DROP VIEW v_window +-- !query 56 schema +struct<> +-- !query 56 output + + + +-- !query 57 SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 55 schema +-- !query 57 schema struct --- !query 55 output +-- !query 57 output 12 1 1 12 5 1 12 9 1 @@ -981,13 +1006,13 @@ NULL 4 0 NULL 8 0 --- !query 56 +-- !query 58 SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 56 schema +-- !query 58 schema struct --- !query 56 output +-- !query 58 output 10 2 2 10 6 2 18 1 1 @@ -1000,13 +1025,13 @@ NULL 3 3 NULL 7 3 --- !query 57 +-- !query 59 SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 57 schema +-- !query 59 schema struct --- !query 57 output +-- !query 59 output 10 3 3 10 7 3 12 4 0 @@ -1019,7 +1044,7 @@ struct --- !query 58 output +-- !query 60 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1040,7 +1065,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 59 +-- !query 61 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1050,9 +1075,9 @@ from union all select null, 43) ss window w as (order by ss.id asc nulls last range between 2 preceding and 2 following) --- !query 59 schema +-- !query 61 schema struct --- !query 59 output +-- !query 61 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1061,7 +1086,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 60 +-- !query 62 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1071,9 +1096,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls first range between 2 preceding and 2 following) --- !query 60 schema +-- !query 62 schema struct --- !query 60 output +-- !query 62 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1082,7 +1107,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 61 +-- !query 63 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1092,9 +1117,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls last range between 2 preceding and 2 following) --- !query 61 schema +-- !query 63 schema struct --- !query 61 output +-- !query 63 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1103,76 +1128,247 @@ NULL 42 42 43 NULL 43 42 43 --- !query 62 +-- !query 64 select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) from range(32764, 32766) x --- !query 62 schema +-- !query 64 schema struct --- !query 62 output +-- !query 64 output 32764 32765 32765 32765 --- !query 63 +-- !query 65 select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) from range(-32766, -32764) x --- !query 63 schema +-- !query 65 schema struct --- !query 63 output +-- !query 65 output -32765 -32766 -32766 -32766 --- !query 64 +-- !query 66 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x --- !query 64 schema +-- !query 66 schema struct --- !query 64 output +-- !query 66 output 2147483644 2147483645 2147483645 2147483645 --- !query 65 +-- !query 67 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x --- !query 65 schema +-- !query 67 schema struct --- !query 65 output +-- !query 67 output -2147483645 -2147483646 -2147483646 -2147483646 --- !query 66 +-- !query 68 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x --- !query 66 schema +-- !query 68 schema struct --- !query 66 output +-- !query 68 output 9223372036854775804 NULL 9223372036854775805 NULL --- !query 67 +-- !query 69 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x --- !query 67 schema +-- !query 69 schema struct --- !query 67 output +-- !query 69 output -9223372036854775805 NULL -9223372036854775806 NULL --- !query 68 +-- !query 70 +SELECT sum(unique1) over (order by four range between unbounded preceding and current row), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 70 schema +struct +-- !query 70 output +12 0 0 +12 4 0 +12 8 0 +27 1 1 +27 5 1 +27 9 1 +35 2 2 +35 6 2 +45 3 3 +45 7 3 + + +-- !query 71 +SELECT sum(unique1) over (order by four range between unbounded preceding and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 71 schema +struct +-- !query 71 output +45 0 0 +45 1 1 +45 2 2 +45 3 3 +45 4 0 +45 5 1 +45 6 2 +45 7 3 +45 8 0 +45 9 1 + + +-- !query 72 +SELECT sum(unique1) over (order by four range between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 72 schema +struct +-- !query 72 output +10 3 3 +10 7 3 +18 2 2 +18 6 2 +33 1 1 +33 5 1 +33 9 1 +45 0 0 +45 4 0 +45 8 0 + + +-- !query 73 +SELECT sum(unique1) over (order by four range between 1 preceding and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 73 schema +struct +-- !query 73 output +18 3 3 +18 7 3 +33 2 2 +33 6 2 +45 0 0 +45 1 1 +45 4 0 +45 5 1 +45 8 0 +45 9 1 + + +-- !query 74 +SELECT sum(unique1) over (order by four range between 1 following and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 74 schema +struct +-- !query 74 output +10 2 2 +10 6 2 +18 1 1 +18 5 1 +18 9 1 +33 0 0 +33 4 0 +33 8 0 +NULL 3 3 +NULL 7 3 + + +-- !query 75 +SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 75 schema +struct +-- !query 75 output +35 0 0 +35 4 0 +35 8 0 +45 1 1 +45 2 2 +45 3 3 +45 5 1 +45 6 2 +45 7 3 +45 9 1 + + +-- !query 76 +SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 76 schema +struct +-- !query 76 output +12 1 1 +12 5 1 +12 9 1 +23 3 3 +23 7 3 +27 2 2 +27 6 2 +NULL 0 0 +NULL 4 0 +NULL 8 0 + + +-- !query 77 +SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 77 schema +struct +-- !query 77 output +10 3 3 +10 7 3 +12 0 0 +12 4 0 +12 8 0 +15 1 1 +15 5 1 +15 9 1 +8 2 2 +8 6 2 + + +-- !query 78 +SELECT sum(unique1) over (partition by ten + order by four range between 0 preceding and 0 following),unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- !query 78 schema +struct +-- !query 78 output +0 0 0 0 +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 0 4 +5 5 1 5 +6 6 2 6 +7 7 3 7 +8 8 0 8 +9 9 1 9 + + +-- !query 79 WITH cte (x) AS ( SELECT * FROM range(1, 35, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) --- !query 68 schema +-- !query 79 schema struct --- !query 68 output +-- !query 79 output 1 4 11 33 13 39 @@ -1192,16 +1388,16 @@ struct --- !query 69 output +-- !query 80 output 1 1 11 11 13 13 @@ -1221,7 +1417,7 @@ struct --- !query 70 output +-- !query 81 output 1 2 1 3 1 7 @@ -1259,7 +1455,7 @@ struct --- !query 71 output +-- !query 82 output 1 3 1 3 1 3 @@ -1297,233 +1493,420 @@ struct --- !query 72 output +-- !query 83 output --- !query 73 +-- !query 84 create table t1 (f1 int, f2 int) using parquet --- !query 73 schema +-- !query 84 schema struct<> --- !query 73 output +-- !query 84 output + + + +-- !query 85 +insert into t1 values (1,1),(1,2),(2,2) +-- !query 85 schema +struct<> +-- !query 85 output + + + +-- !query 86 +select f1, sum(f1) over (partition by f1 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 86 schema +struct<> +-- !query 86 output +org.apache.spark.sql.AnalysisException +cannot resolve '(PARTITION BY default.t1.`f1` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)' due to data type mismatch: A range window frame cannot be used in an unordered window specification.; line 1 pos 24 + + +-- !query 87 +explain +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 87 schema +struct +-- !query 87 output +== Physical Plan == +*Project [f1#x, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL] ++- Window [sum(cast(f1#x as bigint)) windowspecdefinition(f1#x, f2#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, -1, 1)) AS sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL], [f1#x], [f2#x ASC NULLS FIRST] + +- *Sort [f1#x ASC NULLS FIRST, f2#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(f1#x, 200), true + +- *Project [f1#x, f2#x] + +- *Filter ((isnotnull(f1#x) AND isnotnull(f2#x)) AND (f1#x = f2#x)) + +- *ColumnarToRow + +- FileScan parquet default.t1[f1#x,f2#x] Batched: true, DataFilters: [isnotnull(f1#x), isnotnull(f2#x), (f1#x = f2#x)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(f1), IsNotNull(f2)], ReadSchema: struct + + +-- !query 88 +select f1, sum(f1) over (partition by f1 order by f2 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 88 schema +struct +-- !query 88 output +1 1 +2 2 + + +-- !query 89 +select f1, sum(f1) over (partition by f1, f1 order by f2 +range between 2 preceding and 1 preceding) +from t1 where f1 = f2 +-- !query 89 schema +struct +-- !query 89 output +1 NULL +2 NULL + + +-- !query 90 +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) +from t1 where f1 = f2 +-- !query 90 schema +struct +-- !query 90 output +1 NULL +2 NULL +-- !query 91 +explain +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 91 schema +struct +-- !query 91 output +== Physical Plan == +*Project [f1#x, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL] ++- Window [sum(cast(f1#x as bigint)) windowspecdefinition(f1#x, f2#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, -1, 1)) AS sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL], [f1#x], [f2#x ASC NULLS FIRST] + +- *Sort [f1#x ASC NULLS FIRST, f2#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(f1#x, 200), true + +- *Project [f1#x, f2#x] + +- *Filter ((isnotnull(f1#x) AND isnotnull(f2#x)) AND (f1#x = f2#x)) + +- *ColumnarToRow + +- FileScan parquet default.t1[f1#x,f2#x] Batched: true, DataFilters: [isnotnull(f1#x), isnotnull(f2#x), (f1#x = f2#x)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(f1), IsNotNull(f2)], ReadSchema: struct --- !query 74 -insert into t1 values (1,1),(1,2),(2,2) --- !query 74 schema -struct<> --- !query 74 output +-- !query 92 +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 92 schema +struct +-- !query 92 output +1 1 +2 2 --- !query 75 +-- !query 93 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 75 schema +-- !query 93 schema struct --- !query 75 output +-- !query 93 output 1 NULL 2 NULL --- !query 76 +-- !query 94 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 76 schema +-- !query 94 schema struct --- !query 76 output +-- !query 94 output 1 NULL 2 NULL --- !query 77 +-- !query 95 SELECT rank() OVER (ORDER BY length('abc')) --- !query 77 schema +-- !query 95 schema struct --- !query 77 output +-- !query 95 output 1 --- !query 78 +-- !query 96 +EXPLAIN +SELECT * FROM +(SELECT depname, +sum(salary) OVER (PARTITION BY depname) depsalary, +min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary +FROM empsalary) emp +WHERE depname = 'sales' +-- !query 96 schema +struct +-- !query 96 output +== Physical Plan == +*Project [depname#x, depsalary#xL, depminsalary#x] ++- Window [min(salary#x) windowspecdefinition(_w1#x, depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depminsalary#x], [_w1#x, depname#x] + +- *Sort [_w1#x ASC NULLS FIRST, depname#x ASC NULLS FIRST], false, 0 + +- Window [sum(cast(salary#x as bigint)) windowspecdefinition(depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depsalary#xL], [depname#x] + +- *Sort [depname#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(depname#x, 200), true + +- *Project [depname#x, salary#x, concat(depname#x, A) AS _w1#x] + +- *Filter (isnotnull(depname#x) AND (depname#x = sales)) + +- *ColumnarToRow + +- FileScan parquet default.empsalary[depname#x,salary#x] Batched: true, DataFilters: [isnotnull(depname#x), (depname#x = sales)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(depname), EqualTo(depname,sales)], ReadSchema: struct + + +-- !query 97 +EXPLAIN +SELECT * FROM +(SELECT depname, +sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, +min(salary) OVER (PARTITION BY depname) depminsalary +FROM empsalary) emp +WHERE depname = 'sales' +-- !query 97 schema +struct +-- !query 97 output +== Physical Plan == +*Project [depname#x, enroll_salary#xL, depminsalary#x] ++- *Filter (isnotnull(depname#x) AND (depname#x = sales)) + +- Window [sum(cast(salary#x as bigint)) windowspecdefinition(enroll_date#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS enroll_salary#xL], [enroll_date#x] + +- *Sort [enroll_date#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(enroll_date#x, 200), true + +- Window [min(salary#x) windowspecdefinition(depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depminsalary#x], [depname#x] + +- *Sort [depname#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(depname#x, 200), true + +- *Project [depname#x, salary#x, enroll_date#x] + +- *ColumnarToRow + +- FileScan parquet default.empsalary[depname#x,salary#x,enroll_date#x] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct + + +-- !query 98 +EXPLAIN +SELECT * FROM +(SELECT depname, +sum(salary) OVER (PARTITION BY depname order by empno) depsalary, +min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary +FROM empsalary) emp +WHERE depname = 'sales' +-- !query 98 schema +struct +-- !query 98 output +== Physical Plan == +*Project [depname#x, depsalary#xL, depminsalary#x] ++- Window [min(salary#x) windowspecdefinition(depname#x, empno#x, enroll_date#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, unboundedpreceding$(), currentrow$())) AS depminsalary#x], [depname#x, empno#x], [enroll_date#x ASC NULLS FIRST] + +- *Sort [depname#x ASC NULLS FIRST, empno#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST], false, 0 + +- Window [sum(cast(salary#x as bigint)) windowspecdefinition(depname#x, empno#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, unboundedpreceding$(), currentrow$())) AS depsalary#xL], [depname#x], [empno#x ASC NULLS FIRST] + +- *Sort [depname#x ASC NULLS FIRST, empno#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(depname#x, 200), true + +- *Project [depname#x, salary#x, empno#x, enroll_date#x] + +- *Filter (isnotnull(depname#x) AND (depname#x = sales)) + +- *ColumnarToRow + +- FileScan parquet default.empsalary[depname#x,empno#x,salary#x,enroll_date#x] Batched: true, DataFilters: [isnotnull(depname#x), (depname#x = sales)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(depname), EqualTo(depname,sales)], ReadSchema: struct + + +-- !query 99 +EXPLAIN +SELECT +lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), +lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +FROM empsalary +-- !query 99 schema +struct +-- !query 99 output +== Physical Plan == +*Project [lead(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)#x, lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x] ++- Window [lead(1, 1, null) windowspecdefinition(depname#x, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, specifiedwindowframe(RowFrame, 1, 1)) AS lead(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)#x], [depname#x], [salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST] + +- *Project [depname#x, salary#x, enroll_date#x, lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x] + +- Window [lag(1, 1, null) windowspecdefinition(depname#x, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, empno#x ASC NULLS FIRST, specifiedwindowframe(RowFrame, -1, -1)) AS lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x], [depname#x], [salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, empno#x ASC NULLS FIRST] + +- *Sort [depname#x ASC NULLS FIRST, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, empno#x ASC NULLS FIRST], false, 0 + +- Exchange hashpartitioning(depname#x, 200), true + +- *Project [depname#x, salary#x, enroll_date#x, empno#x] + +- *ColumnarToRow + +- FileScan parquet default.empsalary[depname#x,empno#x,salary#x,enroll_date#x] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct + + +-- !query 100 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 78 schema +-- !query 100 schema struct --- !query 78 output +-- !query 100 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 79 +-- !query 101 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 79 schema +-- !query 101 schema struct --- !query 79 output +-- !query 101 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 80 +-- !query 102 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 80 schema +-- !query 102 schema struct --- !query 80 output +-- !query 102 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 81 +-- !query 103 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 81 schema +-- !query 103 schema struct --- !query 81 output +-- !query 103 output 1 2 2 2.5 3 NULL 4 NULL --- !query 82 +-- !query 104 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 82 schema +-- !query 104 schema struct --- !query 82 output +-- !query 104 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 83 +-- !query 105 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 83 schema +-- !query 105 schema struct --- !query 83 output +-- !query 105 output 1 3 2 2 3 NULL 4 NULL --- !query 84 +-- !query 106 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 84 schema +-- !query 106 schema struct --- !query 84 output +-- !query 106 output 1 3 2 2 3 NULL 4 NULL --- !query 85 +-- !query 107 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 85 schema +-- !query 107 schema struct --- !query 85 output +-- !query 107 output 1 3 2 2 3 NULL 4 NULL --- !query 86 +-- !query 108 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 86 schema +-- !query 108 schema struct --- !query 86 output +-- !query 108 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 87 +-- !query 109 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 87 schema +-- !query 109 schema struct --- !query 87 output +-- !query 109 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 88 +-- !query 110 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 88 schema +-- !query 110 schema struct --- !query 88 output +-- !query 110 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 89 +-- !query 111 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 89 schema +-- !query 111 schema struct --- !query 89 output +-- !query 111 output 3 5 6.01 --- !query 90 +-- !query 112 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 90 schema +-- !query 112 schema struct --- !query 90 output +-- !query 112 output 1 2 2 1 3 0 4 0 --- !query 91 +-- !query 113 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 91 schema +-- !query 113 schema struct --- !query 91 output +-- !query 113 output 1 4 2 3 3 2 4 1 --- !query 92 +-- !query 114 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 92 schema +-- !query 114 schema struct --- !query 92 output +-- !query 114 output 0.0 11266.666666666666 13868.750000000002 @@ -1531,12 +1914,12 @@ struct --- !query 93 output +-- !query 115 output 0.0 11266.666666666666 13868.750000000002 @@ -1544,12 +1927,12 @@ struct --- !query 94 output +-- !query 116 output 0.0 11266.666666666666 13868.750000000002 @@ -1557,12 +1940,12 @@ struct --- !query 95 output +-- !query 117 output 0.0 11266.666666666666 13868.750000000002 @@ -1570,12 +1953,12 @@ struct --- !query 96 output +-- !query 118 output 16900.0 18491.666666666668 27129.999999999996 @@ -1583,12 +1966,12 @@ struct --- !query 97 output +-- !query 119 output 16900.0 18491.666666666668 27129.999999999996 @@ -1596,12 +1979,12 @@ struct --- !query 98 output +-- !query 120 output 16900.0 18491.666666666668 27129.999999999996 @@ -1609,12 +1992,12 @@ struct --- !query 99 output +-- !query 121 output 16900.0 18491.666666666668 27129.999999999996 @@ -1622,12 +2005,12 @@ struct --- !query 100 output +-- !query 122 output 16900.0 18491.666666666668 27129.999999999996 @@ -1635,12 +2018,12 @@ struct --- !query 101 output +-- !query 123 output 16900.0 18491.666666666668 27129.999999999996 @@ -1648,12 +2031,12 @@ struct --- !query 102 output +-- !query 124 output 16900.0 18491.666666666668 27129.999999999996 @@ -1661,12 +2044,12 @@ struct --- !query 103 output +-- !query 125 output 16900.0 18491.666666666668 27129.999999999996 @@ -1674,12 +2057,12 @@ struct --- !query 104 output +-- !query 126 output 0.0 106.14455552060438 117.76565713313879 @@ -1688,12 +2071,12 @@ struct --- !query 105 output +-- !query 127 output 0.0 106.14455552060438 117.76565713313879 @@ -1702,12 +2085,12 @@ struct --- !query 106 output +-- !query 128 output 0.0 106.14455552060438 117.76565713313879 @@ -1716,12 +2099,12 @@ struct --- !query 107 output +-- !query 129 output 0.0 106.14455552060438 117.76565713313879 @@ -1730,12 +2113,12 @@ struct --- !query 108 output +-- !query 130 output 130.0 135.9840676942217 164.7118696390761 @@ -1744,12 +2127,12 @@ struct --- !query 109 output +-- !query 131 output 130.0 135.9840676942217 164.7118696390761 @@ -1758,12 +2141,12 @@ struct --- !query 110 output +-- !query 132 output 130.0 135.9840676942217 164.7118696390761 @@ -1772,12 +2155,12 @@ struct --- !query 111 output +-- !query 133 output 130.0 135.9840676942217 164.7118696390761 @@ -1786,12 +2169,12 @@ struct --- !query 112 output +-- !query 134 output 130.0 135.9840676942217 164.7118696390761 @@ -1800,12 +2183,12 @@ struct --- !query 113 output +-- !query 135 output 130.0 135.9840676942217 164.7118696390761 @@ -1814,12 +2197,12 @@ struct --- !query 114 output +-- !query 136 output 130.0 135.9840676942217 164.7118696390761 @@ -1828,12 +2211,12 @@ struct --- !query 115 output +-- !query 137 output 130.0 135.9840676942217 164.7118696390761 @@ -1842,61 +2225,61 @@ struct --- !query 116 output +-- !query 138 output 1 1 2 2 3 NULL 4 NULL --- !query 117 +-- !query 139 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 117 schema +-- !query 139 schema struct --- !query 117 output +-- !query 139 output 1 3 2 2 3 NULL 4 NULL --- !query 118 +-- !query 140 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 118 schema +-- !query 140 schema struct --- !query 118 output +-- !query 140 output 1 3 2 6 3 9 4 7 --- !query 119 +-- !query 141 drop table empsalary --- !query 119 schema +-- !query 141 schema struct<> --- !query 119 output +-- !query 141 output --- !query 120 +-- !query 142 drop table t1 --- !query 120 schema +-- !query 142 schema struct<> --- !query 120 output +-- !query 142 output --- !query 121 +-- !query 143 drop view int4_tbl --- !query 121 schema +-- !query 143 schema struct<> --- !query 121 output +-- !query 143 output From d149949fab4a81c4e8f24bfb6051061f2489158a Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 24 Jul 2019 15:24:24 -0300 Subject: [PATCH 12/25] adds pointer to new jiras Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 66 +-- .../sql-tests/results/pgSQL/window.sql.out | 482 +++++++++++------- 2 files changed, 317 insertions(+), 231 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 407e6d5b944de..cddf7bbeb2673 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -276,7 +276,7 @@ FROM tenk1 WHERE unique1 < 10; -- FROM tenk1 WHERE unique1 < 10 -- WINDOW w AS (order by four range between current row and unbounded following); --- Frame bound value must be a literal. +-- [SPARK-28501] Frame bound value must be a literal. -- SELECT sum(unique1) over -- (order by unique1 -- rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), @@ -585,9 +585,9 @@ FROM tenk1 WHERE unique1 < 10; -- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; --- Window Frame specifiedwindowframe(RangeFrame, -1, 1) must match the required frame specifiedwindowframe(RowFrame, -1, -1); +-- [SPARK-28508] Support for range frame+row frame in the same query -- select last(salary) over(order by enroll_date range between 1 preceding and 1 following), --- lag(salary) over(order by enroll_date range between 1 preceding and 1 following), +-- lag(salary) over(order by enroll_date range between 1 preceding and 1 following), -- salary, enroll_date from empsalary; -- [SPARK-27951] ANSI SQL: NTH_VALUE function @@ -618,13 +618,12 @@ SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); --- mismatched input 'WINDOW' expecting {, 'LIMIT'} --- WITH cte (x) AS ( --- SELECT * FROM range(1, 35, 2) --- ) --- SELECT x, (sum(x) over w) --- FROM cte --- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); +WITH cte (x) AS ( + SELECT * FROM range(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); WITH cte (x) AS ( select 1 union all select 1 union all select 1 union all @@ -642,21 +641,20 @@ SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); --- mismatched input 'WINDOW' expecting {, 'LIMIT'} --- WITH cte (x) AS ( --- select 1 union all select 1 union all select 1 union all --- SELECT * FROM range(5, 49, 2) --- ) --- SELECT x, (sum(x) over w) --- FROM cte --- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM range(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); -select f1, sum(f1) over (partition by f1 +select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) from t1 where f1 = f2; @@ -676,10 +674,9 @@ select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2; --- cannot resolve '(PARTITION BY default.t1.`f1` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)' due to data type mismatch: A range window frame cannot be used in an unordered window specification. --- select f1, sum(f1) over (partition by f1 --- range between 1 preceding and 1 following) --- from t1 where f1 = f2; +select f1, sum(f1) over (partition by f1, +f1 order by f2 range between 1 preceding and 1 following) +from t1 where f1 = f2; explain select f1, sum(f1) over (partition by f1 order by f2 @@ -703,15 +700,14 @@ SELECT rank() OVER (ORDER BY length('abc')); -- [SPARK-28086] Adds `random()` to Spark -- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); --- It is not allowed to use window functions inside WHERE and HAVING clauses; --- SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; +select * from +(select row_number() over (order by salary) rn from empsalary) ss +where rn < 10; --- The query operator `Join` contains one or more unsupported --- expression types Aggregate, Window or Generate. +-- [SPARK-28506] not handling usage of group function and window function at some conditions -- SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; --- The query operator `Aggregate` contains one or more unsupported --- expression types Aggregate, Window or Generate. +-- [SPARK-28506] not handling usage of group function and window function at some conditions -- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; -- [SPARK-28086] Adds `random()` to Spark @@ -726,22 +722,16 @@ SELECT rank() OVER (ORDER BY length('abc')); -- Output not being truncated -- SELECT count() OVER () FROM tenk1; --- Ok, first I migrated a call to `generate_series()`, given by Postgres, to --- the equivalent Spark function, called `range()`. But `range()` seems less --- flexible than `generate_series()` --- SELECT range(1, 101) OVER () FROM empsalary; - --- cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; +-- [SPARK-28065] ntile only accepting positive (>0) values -- SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; -- [SPARK-27951] ANSI SQL: NTH_VALUE function -- SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; --- mismatched input 'FILTER' +-- [SPARK-28500] Adds support for `filter` clause -- SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( -- sum(salary) FILTER (WHERE enroll_date > '2007-01-01') --- ) FILTER (WHERE depname <> 'sales') OVER (ORDER BY depname DESC) AS "filtered_sum", --- depname +-- ) -- FROM empsalary GROUP BY depname; EXPLAIN diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 7c8104824851e..8d43fc6e7c3b2 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 144 +-- Number of queries: 148 -- !query 0 @@ -1418,6 +1418,35 @@ struct +-- !query 81 output +1 1 +11 11 +13 13 +15 15 +17 17 +19 19 +21 21 +23 23 +25 25 +27 27 +29 29 +3 3 +31 31 +33 33 +5 5 +7 7 +9 9 + + +-- !query 82 WITH cte (x) AS ( select 1 union all select 1 union all select 1 union all SELECT * FROM range(5, 49, 2) @@ -1425,9 +1454,9 @@ WITH cte (x) AS ( SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) --- !query 81 schema +-- !query 82 schema struct --- !query 81 output +-- !query 82 output 1 2 1 3 1 7 @@ -1455,7 +1484,7 @@ struct --- !query 82 output +-- !query 83 output 1 3 1 3 1 3 @@ -1493,49 +1522,87 @@ struct +-- !query 84 output +1 3 +1 3 +1 3 +11 11 +13 13 +15 15 +17 17 +19 19 +21 21 +23 23 +25 25 +27 27 +29 29 +31 31 +33 33 +35 35 +37 37 +39 39 +41 41 +43 43 +45 45 +47 47 +5 5 +7 7 +9 9 + + +-- !query 85 SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0 --- !query 83 schema +-- !query 85 schema struct --- !query 83 output +-- !query 85 output --- !query 84 +-- !query 86 create table t1 (f1 int, f2 int) using parquet --- !query 84 schema +-- !query 86 schema struct<> --- !query 84 output +-- !query 86 output --- !query 85 +-- !query 87 insert into t1 values (1,1),(1,2),(2,2) --- !query 85 schema +-- !query 87 schema struct<> --- !query 85 output +-- !query 87 output --- !query 86 -select f1, sum(f1) over (partition by f1 +-- !query 88 +select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 86 schema -struct<> --- !query 86 output -org.apache.spark.sql.AnalysisException -cannot resolve '(PARTITION BY default.t1.`f1` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)' due to data type mismatch: A range window frame cannot be used in an unordered window specification.; line 1 pos 24 +-- !query 88 schema +struct +-- !query 88 output +1 1 +2 2 --- !query 87 +-- !query 89 explain select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 87 schema +-- !query 89 schema struct --- !query 87 output +-- !query 89 output == Physical Plan == *Project [f1#x, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL] +- Window [sum(cast(f1#x as bigint)) windowspecdefinition(f1#x, f2#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, -1, 1)) AS sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL], [f1#x], [f2#x ASC NULLS FIRST] @@ -1547,47 +1614,58 @@ struct +- FileScan parquet default.t1[f1#x,f2#x] Batched: true, DataFilters: [isnotnull(f1#x), isnotnull(f2#x), (f1#x = f2#x)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(f1), IsNotNull(f2)], ReadSchema: struct --- !query 88 +-- !query 90 select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 88 schema +-- !query 90 schema struct --- !query 88 output +-- !query 90 output 1 1 2 2 --- !query 89 +-- !query 91 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 89 schema +-- !query 91 schema struct --- !query 89 output +-- !query 91 output 1 NULL 2 NULL --- !query 90 +-- !query 92 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 90 schema +-- !query 92 schema struct --- !query 90 output +-- !query 92 output 1 NULL 2 NULL --- !query 91 +-- !query 93 +select f1, sum(f1) over (partition by f1, +f1 order by f2 range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 93 schema +struct +-- !query 93 output +1 1 +2 2 + + +-- !query 94 explain select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 91 schema +-- !query 94 schema struct --- !query 91 output +-- !query 94 output == Physical Plan == *Project [f1#x, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL] +- Window [sum(cast(f1#x as bigint)) windowspecdefinition(f1#x, f2#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, -1, 1)) AS sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL], [f1#x], [f2#x ASC NULLS FIRST] @@ -1599,48 +1677,66 @@ struct +- FileScan parquet default.t1[f1#x,f2#x] Batched: true, DataFilters: [isnotnull(f1#x), isnotnull(f2#x), (f1#x = f2#x)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(f1), IsNotNull(f2)], ReadSchema: struct --- !query 92 +-- !query 95 select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 92 schema +-- !query 95 schema struct --- !query 92 output +-- !query 95 output 1 1 2 2 --- !query 93 +-- !query 96 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 93 schema +-- !query 96 schema struct --- !query 93 output +-- !query 96 output 1 NULL 2 NULL --- !query 94 +-- !query 97 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 94 schema +-- !query 97 schema struct --- !query 94 output +-- !query 97 output 1 NULL 2 NULL --- !query 95 +-- !query 98 SELECT rank() OVER (ORDER BY length('abc')) --- !query 95 schema +-- !query 98 schema struct --- !query 95 output +-- !query 98 output 1 --- !query 96 +-- !query 99 +select * from +(select row_number() over (order by salary) rn from empsalary) ss +where rn < 10 +-- !query 99 schema +struct +-- !query 99 output +1 +2 +3 +4 +5 +6 +7 +8 +9 + + +-- !query 100 EXPLAIN SELECT * FROM (SELECT depname, @@ -1648,9 +1744,9 @@ sum(salary) OVER (PARTITION BY depname) depsalary, min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary FROM empsalary) emp WHERE depname = 'sales' --- !query 96 schema +-- !query 100 schema struct --- !query 96 output +-- !query 100 output == Physical Plan == *Project [depname#x, depsalary#xL, depminsalary#x] +- Window [min(salary#x) windowspecdefinition(_w1#x, depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depminsalary#x], [_w1#x, depname#x] @@ -1664,7 +1760,7 @@ struct +- FileScan parquet default.empsalary[depname#x,salary#x] Batched: true, DataFilters: [isnotnull(depname#x), (depname#x = sales)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(depname), EqualTo(depname,sales)], ReadSchema: struct --- !query 97 +-- !query 101 EXPLAIN SELECT * FROM (SELECT depname, @@ -1672,9 +1768,9 @@ sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, min(salary) OVER (PARTITION BY depname) depminsalary FROM empsalary) emp WHERE depname = 'sales' --- !query 97 schema +-- !query 101 schema struct --- !query 97 output +-- !query 101 output == Physical Plan == *Project [depname#x, enroll_salary#xL, depminsalary#x] +- *Filter (isnotnull(depname#x) AND (depname#x = sales)) @@ -1689,7 +1785,7 @@ struct +- FileScan parquet default.empsalary[depname#x,salary#x,enroll_date#x] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct --- !query 98 +-- !query 102 EXPLAIN SELECT * FROM (SELECT depname, @@ -1697,9 +1793,9 @@ sum(salary) OVER (PARTITION BY depname order by empno) depsalary, min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary FROM empsalary) emp WHERE depname = 'sales' --- !query 98 schema +-- !query 102 schema struct --- !query 98 output +-- !query 102 output == Physical Plan == *Project [depname#x, depsalary#xL, depminsalary#x] +- Window [min(salary#x) windowspecdefinition(depname#x, empno#x, enroll_date#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, unboundedpreceding$(), currentrow$())) AS depminsalary#x], [depname#x, empno#x], [enroll_date#x ASC NULLS FIRST] @@ -1713,15 +1809,15 @@ struct +- FileScan parquet default.empsalary[depname#x,empno#x,salary#x,enroll_date#x] Batched: true, DataFilters: [isnotnull(depname#x), (depname#x = sales)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(depname), EqualTo(depname,sales)], ReadSchema: struct --- !query 99 +-- !query 103 EXPLAIN SELECT lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) FROM empsalary --- !query 99 schema +-- !query 103 schema struct --- !query 99 output +-- !query 103 output == Physical Plan == *Project [lead(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)#x, lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x] +- Window [lead(1, 1, null) windowspecdefinition(depname#x, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, specifiedwindowframe(RowFrame, 1, 1)) AS lead(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)#x], [depname#x], [salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST] @@ -1734,179 +1830,179 @@ struct +- FileScan parquet default.empsalary[depname#x,empno#x,salary#x,enroll_date#x] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct --- !query 100 +-- !query 104 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 100 schema +-- !query 104 schema struct --- !query 100 output +-- !query 104 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 101 +-- !query 105 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 101 schema +-- !query 105 schema struct --- !query 101 output +-- !query 105 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 102 +-- !query 106 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 102 schema +-- !query 106 schema struct --- !query 102 output +-- !query 106 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 103 +-- !query 107 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 103 schema +-- !query 107 schema struct --- !query 103 output +-- !query 107 output 1 2 2 2.5 3 NULL 4 NULL --- !query 104 +-- !query 108 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 104 schema +-- !query 108 schema struct --- !query 104 output +-- !query 108 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 105 +-- !query 109 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 105 schema +-- !query 109 schema struct --- !query 105 output +-- !query 109 output 1 3 2 2 3 NULL 4 NULL --- !query 106 +-- !query 110 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 106 schema +-- !query 110 schema struct --- !query 106 output +-- !query 110 output 1 3 2 2 3 NULL 4 NULL --- !query 107 +-- !query 111 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 107 schema +-- !query 111 schema struct --- !query 107 output +-- !query 111 output 1 3 2 2 3 NULL 4 NULL --- !query 108 +-- !query 112 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 108 schema +-- !query 112 schema struct --- !query 108 output +-- !query 112 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 109 +-- !query 113 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 109 schema +-- !query 113 schema struct --- !query 109 output +-- !query 113 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 110 +-- !query 114 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 110 schema +-- !query 114 schema struct --- !query 110 output +-- !query 114 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 111 +-- !query 115 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 111 schema +-- !query 115 schema struct --- !query 111 output +-- !query 115 output 3 5 6.01 --- !query 112 +-- !query 116 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 112 schema +-- !query 116 schema struct --- !query 112 output +-- !query 116 output 1 2 2 1 3 0 4 0 --- !query 113 +-- !query 117 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 113 schema +-- !query 117 schema struct --- !query 113 output +-- !query 117 output 1 4 2 3 3 2 4 1 --- !query 114 +-- !query 118 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 114 schema +-- !query 118 schema struct --- !query 114 output +-- !query 118 output 0.0 11266.666666666666 13868.750000000002 @@ -1914,12 +2010,12 @@ struct --- !query 115 output +-- !query 119 output 0.0 11266.666666666666 13868.750000000002 @@ -1927,12 +2023,12 @@ struct --- !query 116 output +-- !query 120 output 0.0 11266.666666666666 13868.750000000002 @@ -1940,12 +2036,12 @@ struct --- !query 117 output +-- !query 121 output 0.0 11266.666666666666 13868.750000000002 @@ -1953,12 +2049,12 @@ struct --- !query 118 output +-- !query 122 output 16900.0 18491.666666666668 27129.999999999996 @@ -1966,12 +2062,12 @@ struct --- !query 119 output +-- !query 123 output 16900.0 18491.666666666668 27129.999999999996 @@ -1979,12 +2075,12 @@ struct --- !query 120 output +-- !query 124 output 16900.0 18491.666666666668 27129.999999999996 @@ -1992,12 +2088,12 @@ struct --- !query 121 output +-- !query 125 output 16900.0 18491.666666666668 27129.999999999996 @@ -2005,12 +2101,12 @@ struct --- !query 122 output +-- !query 126 output 16900.0 18491.666666666668 27129.999999999996 @@ -2018,12 +2114,12 @@ struct --- !query 123 output +-- !query 127 output 16900.0 18491.666666666668 27129.999999999996 @@ -2031,12 +2127,12 @@ struct --- !query 124 output +-- !query 128 output 16900.0 18491.666666666668 27129.999999999996 @@ -2044,12 +2140,12 @@ struct --- !query 125 output +-- !query 129 output 16900.0 18491.666666666668 27129.999999999996 @@ -2057,12 +2153,12 @@ struct --- !query 126 output +-- !query 130 output 0.0 106.14455552060438 117.76565713313879 @@ -2071,12 +2167,12 @@ struct --- !query 127 output +-- !query 131 output 0.0 106.14455552060438 117.76565713313879 @@ -2085,12 +2181,12 @@ struct --- !query 128 output +-- !query 132 output 0.0 106.14455552060438 117.76565713313879 @@ -2099,12 +2195,12 @@ struct --- !query 129 output +-- !query 133 output 0.0 106.14455552060438 117.76565713313879 @@ -2113,12 +2209,12 @@ struct --- !query 130 output +-- !query 134 output 130.0 135.9840676942217 164.7118696390761 @@ -2127,12 +2223,12 @@ struct --- !query 131 output +-- !query 135 output 130.0 135.9840676942217 164.7118696390761 @@ -2141,12 +2237,12 @@ struct --- !query 132 output +-- !query 136 output 130.0 135.9840676942217 164.7118696390761 @@ -2155,12 +2251,12 @@ struct --- !query 133 output +-- !query 137 output 130.0 135.9840676942217 164.7118696390761 @@ -2169,12 +2265,12 @@ struct --- !query 134 output +-- !query 138 output 130.0 135.9840676942217 164.7118696390761 @@ -2183,12 +2279,12 @@ struct --- !query 135 output +-- !query 139 output 130.0 135.9840676942217 164.7118696390761 @@ -2197,12 +2293,12 @@ struct --- !query 136 output +-- !query 140 output 130.0 135.9840676942217 164.7118696390761 @@ -2211,12 +2307,12 @@ struct --- !query 137 output +-- !query 141 output 130.0 135.9840676942217 164.7118696390761 @@ -2225,61 +2321,61 @@ struct --- !query 138 output +-- !query 142 output 1 1 2 2 3 NULL 4 NULL --- !query 139 +-- !query 143 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 139 schema +-- !query 143 schema struct --- !query 139 output +-- !query 143 output 1 3 2 2 3 NULL 4 NULL --- !query 140 +-- !query 144 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 140 schema +-- !query 144 schema struct --- !query 140 output +-- !query 144 output 1 3 2 6 3 9 4 7 --- !query 141 +-- !query 145 drop table empsalary --- !query 141 schema +-- !query 145 schema struct<> --- !query 141 output +-- !query 145 output --- !query 142 +-- !query 146 drop table t1 --- !query 142 schema +-- !query 146 schema struct<> --- !query 142 output +-- !query 146 output --- !query 143 +-- !query 147 drop view int4_tbl --- !query 143 schema +-- !query 147 schema struct<> --- !query 143 output +-- !query 147 output From 7ab994769ce40cb0ab1a5760d73399213cebd2fa Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 25 Jul 2019 10:45:12 -0300 Subject: [PATCH 13/25] commented out calls to EXPLAIN clause Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 86 ++-- .../sql-tests/results/pgSQL/window.sql.out | 455 ++++++------------ 2 files changed, 202 insertions(+), 339 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index cddf7bbeb2673..3678791154dcf 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -658,13 +658,14 @@ select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) from t1 where f1 = f2; -explain -select f1, sum(f1) over (partition by f1 order by f2 -range between 1 preceding and 1 following) -from t1 where f1 = f2; -select f1, sum(f1) over (partition by f1 order by f2 - range between 1 preceding and 1 following) -from t1 where f1 = f2; +-- Since EXPLAIN clause rely on host physical location, it is commented out +-- explain +-- select f1, sum(f1) over (partition by f1 order by f2 +-- range between 1 preceding and 1 following) +-- from t1 where f1 = f2; +-- select f1, sum(f1) over (partition by f1 order by f2 +-- range between 1 preceding and 1 following) +-- from t1 where f1 = f2; select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) @@ -678,10 +679,11 @@ select f1, sum(f1) over (partition by f1, f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2; -explain -select f1, sum(f1) over (partition by f1 order by f2 -range between 1 preceding and 1 following) -from t1 where f1 = f2; +-- Since EXPLAIN clause rely on host physical location, it is commented out +-- explain +-- select f1, sum(f1) over (partition by f1 order by f2 +-- range between 1 preceding and 1 following) +-- from t1 where f1 = f2; select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) @@ -734,35 +736,39 @@ where rn < 10; -- ) -- FROM empsalary GROUP BY depname; -EXPLAIN -SELECT * FROM -(SELECT depname, -sum(salary) OVER (PARTITION BY depname) depsalary, -min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary -FROM empsalary) emp -WHERE depname = 'sales'; - -EXPLAIN -SELECT * FROM -(SELECT depname, -sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, -min(salary) OVER (PARTITION BY depname) depminsalary -FROM empsalary) emp -WHERE depname = 'sales'; - -EXPLAIN -SELECT * FROM -(SELECT depname, -sum(salary) OVER (PARTITION BY depname order by empno) depsalary, -min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary -FROM empsalary) emp -WHERE depname = 'sales'; - -EXPLAIN -SELECT -lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), -lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) -FROM empsalary; +-- Since EXPLAIN clause rely on host physical location, it is commented out +-- EXPLAIN +-- SELECT * FROM +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY depname) depsalary, +-- min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary +-- FROM empsalary) emp +-- WHERE depname = 'sales'; + +-- Since EXPLAIN clause rely on host physical location, it is commented out +-- EXPLAIN +-- SELECT * FROM +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, +-- min(salary) OVER (PARTITION BY depname) depminsalary +-- FROM empsalary) emp +-- WHERE depname = 'sales'; + +-- Since EXPLAIN clause rely on host physical location, it is commented out +-- EXPLAIN +-- SELECT * FROM +-- (SELECT depname, +-- sum(salary) OVER (PARTITION BY depname order by empno) depsalary, +-- min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary +-- FROM empsalary) emp +-- WHERE depname = 'sales'; + +-- Since EXPLAIN clause rely on host physical location, it is commented out +-- EXPLAIN +-- SELECT +-- lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), +-- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +-- FROM empsalary; SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 8d43fc6e7c3b2..52e95fc96fcf8 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 148 +-- Number of queries: 141 -- !query 0 @@ -1596,135 +1596,86 @@ struct --- !query 89 output -== Physical Plan == -*Project [f1#x, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL] -+- Window [sum(cast(f1#x as bigint)) windowspecdefinition(f1#x, f2#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, -1, 1)) AS sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL], [f1#x], [f2#x ASC NULLS FIRST] - +- *Sort [f1#x ASC NULLS FIRST, f2#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(f1#x, 200), true - +- *Project [f1#x, f2#x] - +- *Filter ((isnotnull(f1#x) AND isnotnull(f2#x)) AND (f1#x = f2#x)) - +- *ColumnarToRow - +- FileScan parquet default.t1[f1#x,f2#x] Batched: true, DataFilters: [isnotnull(f1#x), isnotnull(f2#x), (f1#x = f2#x)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(f1), IsNotNull(f2)], ReadSchema: struct - - --- !query 90 -select f1, sum(f1) over (partition by f1 order by f2 - range between 1 preceding and 1 following) -from t1 where f1 = f2 --- !query 90 schema -struct --- !query 90 output -1 1 -2 2 - - --- !query 91 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 91 schema +-- !query 89 schema struct --- !query 91 output +-- !query 89 output 1 NULL 2 NULL --- !query 92 +-- !query 90 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 92 schema +-- !query 90 schema struct --- !query 92 output +-- !query 90 output 1 NULL 2 NULL --- !query 93 +-- !query 91 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 93 schema +-- !query 91 schema struct --- !query 93 output +-- !query 91 output 1 1 2 2 --- !query 94 -explain -select f1, sum(f1) over (partition by f1 order by f2 -range between 1 preceding and 1 following) -from t1 where f1 = f2 --- !query 94 schema -struct --- !query 94 output -== Physical Plan == -*Project [f1#x, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL] -+- Window [sum(cast(f1#x as bigint)) windowspecdefinition(f1#x, f2#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, -1, 1)) AS sum(f1) OVER (PARTITION BY f1 ORDER BY f2 ASC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)#xL], [f1#x], [f2#x ASC NULLS FIRST] - +- *Sort [f1#x ASC NULLS FIRST, f2#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(f1#x, 200), true - +- *Project [f1#x, f2#x] - +- *Filter ((isnotnull(f1#x) AND isnotnull(f2#x)) AND (f1#x = f2#x)) - +- *ColumnarToRow - +- FileScan parquet default.t1[f1#x,f2#x] Batched: true, DataFilters: [isnotnull(f1#x), isnotnull(f2#x), (f1#x = f2#x)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(f1), IsNotNull(f2)], ReadSchema: struct - - --- !query 95 +-- !query 92 select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 95 schema +-- !query 92 schema struct --- !query 95 output +-- !query 92 output 1 1 2 2 --- !query 96 +-- !query 93 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 96 schema +-- !query 93 schema struct --- !query 96 output +-- !query 93 output 1 NULL 2 NULL --- !query 97 +-- !query 94 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 97 schema +-- !query 94 schema struct --- !query 97 output +-- !query 94 output 1 NULL 2 NULL --- !query 98 +-- !query 95 SELECT rank() OVER (ORDER BY length('abc')) --- !query 98 schema +-- !query 95 schema struct --- !query 98 output +-- !query 95 output 1 --- !query 99 +-- !query 96 select * from (select row_number() over (order by salary) rn from empsalary) ss where rn < 10 --- !query 99 schema +-- !query 96 schema struct --- !query 99 output +-- !query 96 output 1 2 3 @@ -1736,273 +1687,179 @@ struct 9 --- !query 100 -EXPLAIN -SELECT * FROM -(SELECT depname, -sum(salary) OVER (PARTITION BY depname) depsalary, -min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary -FROM empsalary) emp -WHERE depname = 'sales' --- !query 100 schema -struct --- !query 100 output -== Physical Plan == -*Project [depname#x, depsalary#xL, depminsalary#x] -+- Window [min(salary#x) windowspecdefinition(_w1#x, depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depminsalary#x], [_w1#x, depname#x] - +- *Sort [_w1#x ASC NULLS FIRST, depname#x ASC NULLS FIRST], false, 0 - +- Window [sum(cast(salary#x as bigint)) windowspecdefinition(depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depsalary#xL], [depname#x] - +- *Sort [depname#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(depname#x, 200), true - +- *Project [depname#x, salary#x, concat(depname#x, A) AS _w1#x] - +- *Filter (isnotnull(depname#x) AND (depname#x = sales)) - +- *ColumnarToRow - +- FileScan parquet default.empsalary[depname#x,salary#x] Batched: true, DataFilters: [isnotnull(depname#x), (depname#x = sales)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(depname), EqualTo(depname,sales)], ReadSchema: struct - - --- !query 101 -EXPLAIN -SELECT * FROM -(SELECT depname, -sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, -min(salary) OVER (PARTITION BY depname) depminsalary -FROM empsalary) emp -WHERE depname = 'sales' --- !query 101 schema -struct --- !query 101 output -== Physical Plan == -*Project [depname#x, enroll_salary#xL, depminsalary#x] -+- *Filter (isnotnull(depname#x) AND (depname#x = sales)) - +- Window [sum(cast(salary#x as bigint)) windowspecdefinition(enroll_date#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS enroll_salary#xL], [enroll_date#x] - +- *Sort [enroll_date#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(enroll_date#x, 200), true - +- Window [min(salary#x) windowspecdefinition(depname#x, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS depminsalary#x], [depname#x] - +- *Sort [depname#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(depname#x, 200), true - +- *Project [depname#x, salary#x, enroll_date#x] - +- *ColumnarToRow - +- FileScan parquet default.empsalary[depname#x,salary#x,enroll_date#x] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct - - --- !query 102 -EXPLAIN -SELECT * FROM -(SELECT depname, -sum(salary) OVER (PARTITION BY depname order by empno) depsalary, -min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary -FROM empsalary) emp -WHERE depname = 'sales' --- !query 102 schema -struct --- !query 102 output -== Physical Plan == -*Project [depname#x, depsalary#xL, depminsalary#x] -+- Window [min(salary#x) windowspecdefinition(depname#x, empno#x, enroll_date#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, unboundedpreceding$(), currentrow$())) AS depminsalary#x], [depname#x, empno#x], [enroll_date#x ASC NULLS FIRST] - +- *Sort [depname#x ASC NULLS FIRST, empno#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST], false, 0 - +- Window [sum(cast(salary#x as bigint)) windowspecdefinition(depname#x, empno#x ASC NULLS FIRST, specifiedwindowframe(RangeFrame, unboundedpreceding$(), currentrow$())) AS depsalary#xL], [depname#x], [empno#x ASC NULLS FIRST] - +- *Sort [depname#x ASC NULLS FIRST, empno#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(depname#x, 200), true - +- *Project [depname#x, salary#x, empno#x, enroll_date#x] - +- *Filter (isnotnull(depname#x) AND (depname#x = sales)) - +- *ColumnarToRow - +- FileScan parquet default.empsalary[depname#x,empno#x,salary#x,enroll_date#x] Batched: true, DataFilters: [isnotnull(depname#x), (depname#x = sales)], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [IsNotNull(depname), EqualTo(depname,sales)], ReadSchema: struct - - --- !query 103 -EXPLAIN -SELECT -lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), -lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) -FROM empsalary --- !query 103 schema -struct --- !query 103 output -== Physical Plan == -*Project [lead(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)#x, lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x] -+- Window [lead(1, 1, null) windowspecdefinition(depname#x, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, specifiedwindowframe(RowFrame, 1, 1)) AS lead(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)#x], [depname#x], [salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST] - +- *Project [depname#x, salary#x, enroll_date#x, lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x] - +- Window [lag(1, 1, null) windowspecdefinition(depname#x, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, empno#x ASC NULLS FIRST, specifiedwindowframe(RowFrame, -1, -1)) AS lag(1, 1, NULL) OVER (PARTITION BY depname ORDER BY salary ASC NULLS FIRST, enroll_date ASC NULLS FIRST, empno ASC NULLS FIRST ROWS BETWEEN -1 FOLLOWING AND -1 FOLLOWING)#x], [depname#x], [salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, empno#x ASC NULLS FIRST] - +- *Sort [depname#x ASC NULLS FIRST, salary#x ASC NULLS FIRST, enroll_date#x ASC NULLS FIRST, empno#x ASC NULLS FIRST], false, 0 - +- Exchange hashpartitioning(depname#x, 200), true - +- *Project [depname#x, salary#x, enroll_date#x, empno#x] - +- *ColumnarToRow - +- FileScan parquet default.empsalary[depname#x,empno#x,salary#x,enroll_date#x] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex[file:/home/dguedes/Workspace/spark/sql/core/spark-warehouse/org.apache.spark.sq..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct - - --- !query 104 +-- !query 97 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 104 schema +-- !query 97 schema struct --- !query 104 output +-- !query 97 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 105 +-- !query 98 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 105 schema +-- !query 98 schema struct --- !query 105 output +-- !query 98 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 106 +-- !query 99 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 106 schema +-- !query 99 schema struct --- !query 106 output +-- !query 99 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 107 +-- !query 100 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 107 schema +-- !query 100 schema struct --- !query 107 output +-- !query 100 output 1 2 2 2.5 3 NULL 4 NULL --- !query 108 +-- !query 101 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 108 schema +-- !query 101 schema struct --- !query 108 output +-- !query 101 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 109 +-- !query 102 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 109 schema +-- !query 102 schema struct --- !query 109 output +-- !query 102 output 1 3 2 2 3 NULL 4 NULL --- !query 110 +-- !query 103 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 110 schema +-- !query 103 schema struct --- !query 110 output +-- !query 103 output 1 3 2 2 3 NULL 4 NULL --- !query 111 +-- !query 104 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 111 schema +-- !query 104 schema struct --- !query 111 output +-- !query 104 output 1 3 2 2 3 NULL 4 NULL --- !query 112 +-- !query 105 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 112 schema +-- !query 105 schema struct --- !query 112 output +-- !query 105 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 113 +-- !query 106 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 113 schema +-- !query 106 schema struct --- !query 113 output +-- !query 106 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 114 +-- !query 107 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 114 schema +-- !query 107 schema struct --- !query 114 output +-- !query 107 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 115 +-- !query 108 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 115 schema +-- !query 108 schema struct --- !query 115 output +-- !query 108 output 3 5 6.01 --- !query 116 +-- !query 109 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 116 schema +-- !query 109 schema struct --- !query 116 output +-- !query 109 output 1 2 2 1 3 0 4 0 --- !query 117 +-- !query 110 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 117 schema +-- !query 110 schema struct --- !query 117 output +-- !query 110 output 1 4 2 3 3 2 4 1 --- !query 118 +-- !query 111 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 118 schema +-- !query 111 schema struct --- !query 118 output +-- !query 111 output 0.0 11266.666666666666 13868.750000000002 @@ -2010,12 +1867,12 @@ struct --- !query 119 output +-- !query 112 output 0.0 11266.666666666666 13868.750000000002 @@ -2023,12 +1880,12 @@ struct --- !query 120 output +-- !query 113 output 0.0 11266.666666666666 13868.750000000002 @@ -2036,12 +1893,12 @@ struct --- !query 121 output +-- !query 114 output 0.0 11266.666666666666 13868.750000000002 @@ -2049,12 +1906,12 @@ struct --- !query 122 output +-- !query 115 output 16900.0 18491.666666666668 27129.999999999996 @@ -2062,12 +1919,12 @@ struct --- !query 123 output +-- !query 116 output 16900.0 18491.666666666668 27129.999999999996 @@ -2075,12 +1932,12 @@ struct --- !query 124 output +-- !query 117 output 16900.0 18491.666666666668 27129.999999999996 @@ -2088,12 +1945,12 @@ struct --- !query 125 output +-- !query 118 output 16900.0 18491.666666666668 27129.999999999996 @@ -2101,12 +1958,12 @@ struct --- !query 126 output +-- !query 119 output 16900.0 18491.666666666668 27129.999999999996 @@ -2114,12 +1971,12 @@ struct --- !query 127 output +-- !query 120 output 16900.0 18491.666666666668 27129.999999999996 @@ -2127,12 +1984,12 @@ struct --- !query 128 output +-- !query 121 output 16900.0 18491.666666666668 27129.999999999996 @@ -2140,12 +1997,12 @@ struct --- !query 129 output +-- !query 122 output 16900.0 18491.666666666668 27129.999999999996 @@ -2153,12 +2010,12 @@ struct --- !query 130 output +-- !query 123 output 0.0 106.14455552060438 117.76565713313879 @@ -2167,12 +2024,12 @@ struct --- !query 131 output +-- !query 124 output 0.0 106.14455552060438 117.76565713313879 @@ -2181,12 +2038,12 @@ struct --- !query 132 output +-- !query 125 output 0.0 106.14455552060438 117.76565713313879 @@ -2195,12 +2052,12 @@ struct --- !query 133 output +-- !query 126 output 0.0 106.14455552060438 117.76565713313879 @@ -2209,12 +2066,12 @@ struct --- !query 134 output +-- !query 127 output 130.0 135.9840676942217 164.7118696390761 @@ -2223,12 +2080,12 @@ struct --- !query 135 output +-- !query 128 output 130.0 135.9840676942217 164.7118696390761 @@ -2237,12 +2094,12 @@ struct --- !query 136 output +-- !query 129 output 130.0 135.9840676942217 164.7118696390761 @@ -2251,12 +2108,12 @@ struct --- !query 137 output +-- !query 130 output 130.0 135.9840676942217 164.7118696390761 @@ -2265,12 +2122,12 @@ struct --- !query 138 output +-- !query 131 output 130.0 135.9840676942217 164.7118696390761 @@ -2279,12 +2136,12 @@ struct --- !query 139 output +-- !query 132 output 130.0 135.9840676942217 164.7118696390761 @@ -2293,12 +2150,12 @@ struct --- !query 140 output +-- !query 133 output 130.0 135.9840676942217 164.7118696390761 @@ -2307,12 +2164,12 @@ struct --- !query 141 output +-- !query 134 output 130.0 135.9840676942217 164.7118696390761 @@ -2321,61 +2178,61 @@ struct --- !query 142 output +-- !query 135 output 1 1 2 2 3 NULL 4 NULL --- !query 143 +-- !query 136 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 143 schema +-- !query 136 schema struct --- !query 143 output +-- !query 136 output 1 3 2 2 3 NULL 4 NULL --- !query 144 +-- !query 137 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 144 schema +-- !query 137 schema struct --- !query 144 output +-- !query 137 output 1 3 2 6 3 9 4 7 --- !query 145 +-- !query 138 drop table empsalary --- !query 145 schema +-- !query 138 schema struct<> --- !query 145 output +-- !query 138 output --- !query 146 +-- !query 139 drop table t1 --- !query 146 schema +-- !query 139 schema struct<> --- !query 146 output +-- !query 139 output --- !query 147 +-- !query 140 drop view int4_tbl --- !query 147 schema +-- !query 140 schema struct<> --- !query 147 output +-- !query 140 output From 94bb6e314d9db33c8d096e889c3e9ae4a5b7f3a5 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 29 Jul 2019 09:27:08 -0300 Subject: [PATCH 14/25] update with JIRAs Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 279 ++++- .../sql-tests/results/pgSQL/window.sql.out | 1005 +++++++++++------ 2 files changed, 904 insertions(+), 380 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 3678791154dcf..e6b185cb6d06d 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -28,6 +28,7 @@ SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname) FROM emps SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary; +-- with GROUP BY SELECT four, ten, SUM(SUM(four)) OVER (PARTITION BY four), AVG(ten) FROM tenk1 GROUP BY four, ten ORDER BY four, ten; @@ -36,12 +37,15 @@ SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PA -- [SPARK-28064] Order by does not accept a call to rank() -- SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w; +-- empty window specification SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10; SELECT COUNT(*) OVER w FROM tenk1 WHERE unique2 < 10 WINDOW w AS (); +-- no window operation SELECT four FROM tenk1 WHERE FALSE WINDOW w AS (PARTITION BY ten); +-- cumulative aggregate SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10; SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10; @@ -73,6 +77,7 @@ SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FRO SELECT first(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; +-- last returns the last row of the frame, which is CURRENT ROW in ORDER BY window. SELECT last(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; SELECT last(ten) OVER (PARTITION BY four), ten, four FROM @@ -92,6 +97,7 @@ SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + sum(hundred) OVER (PARTITION BY four ORDER BY ten)) AS cntsum FROM tenk1 WHERE unique2 < 10; +-- opexpr with different windows evaluation. SELECT * FROM( SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, @@ -105,22 +111,28 @@ SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHE SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER win AS wsum FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten); +-- more than one window with GROUP BY SELECT sum(salary), -row_number() OVER (ORDER BY depname), -sum(sum(salary)) OVER (ORDER BY depname DESC) + row_number() OVER (ORDER BY depname), + sum(sum(salary)) OVER (ORDER BY depname DESC) FROM empsalary GROUP BY depname; +-- identical windows with different names SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); --- Correlated scalar subqueries must be aggregated: Filter (outer(unique2#x) = unique2#x) +-- subplan +-- [SPARK-28553] subqueries must be aggregated before hand -- SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) -- FROM tenk1 s WHERE unique2 < 10; +-- empty table SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s; +-- mixture of agg/wfunc in the same window SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC); +-- strict aggs -- no viable alternative at input 'year' -- SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( -- SELECT *, @@ -138,18 +150,23 @@ create temporary view int4_tbl as select * from values (-2147483647) as int4_tbl(f1); +-- window function over ungrouped agg over empty row set (bug before 9.1) SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42; +-- window function with ORDER BY an expression involving aggregates (9.1 bug) select ten, sum(unique1) + sum(unique2) as res, rank() over (order by sum(unique1) + sum(unique2)) as rank from tenk1 group by ten order by ten; -select first(max(x)) over (), y - from (select unique1 as x, ten+four as y from tenk1) ss - group by y; +-- window and aggregate with GROUP BY expression (9.2 bug) +-- explain +-- select first(max(x)) over (), y +-- from (select unique1 as x, ten+four as y from tenk1) ss +-- group by y; +-- test non-default frame specifications SELECT four, ten, sum(ten) over (partition by four order by ten), last(ten) over (partition by four order by ten) @@ -327,6 +344,8 @@ DROP VIEW v_window; -- SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i -- FROM range(now(), now()+'100 days', '1 hour') i; +-- RANGE offset PRECEDING/FOLLOWING tests + SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10; @@ -450,6 +469,7 @@ FROM tenk1 WHERE unique1 < 10; -- exclude current row), -- salary, enroll_date from empsalary; +-- RANGE offset PRECEDING/FOLLOWING with null values select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -490,6 +510,8 @@ from window w as (order by ss.id desc nulls last range between 2 preceding and 2 following); +-- Check overflow behavior for various integer sizes + select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) from range(32764, 32766) x; @@ -508,6 +530,208 @@ from range(9223372036854775804, 9223372036854775806) x; select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x; +-- Test in_range for other numeric datatypes + +create table numerics ( + id int, + f_float4 float, + f_float8 float, + f_numeric int +) using parquet; + +-- [SPARK-27768] Infinity, -Infinity, NaN should be recognized in a case insensitive manner +insert into numerics values +(1, -3, -3, -3), +(2, -1, -1, -1), +(3, 0, 0, 0), +(4, 1.1, 1.1, 1.1), +(5, 1.12, 1.12, 1.12), +(6, 2, 2, 2), +(7, 100, 100, 100); +--(8, 'infinity', 'infinity', '1000'), +--(9, 'NaN', 'NaN', 'NaN'); +--(0, '-infinity', '-infinity', '-1000'), -- numeric type lacks infinities + + +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1 following); + +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1.1 following); + +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' preceding and 'inf' following); + +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 1.1 preceding and 'NaN' following); -- error, NaN disallowed + +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1 following); + +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1.1 following); + +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' preceding and 'inf' following); + +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 1.1 preceding and 'NaN' following); -- error, NaN disallowed + +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1 following); + +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1 following); + +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1 following); -- currently unsupported + +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1.1 preceding and 'NaN' following); -- error, NaN disallowed + +-- Test in_range for other datetime datatypes + +-- Spark only supports timestamp +create table datetimes ( + id int, + f_time timestamp, + f_timetz timestamp, + f_interval timestamp, + f_timestamptz timestamp, + f_timestamp timestamp +) using parquet; + +insert into datetimes values +(1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), +(2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(3, '13:00', '13:00 BST', '3 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(4, '14:00', '14:00 BST', '4 years', '2002-10-19 10:23:54+01', '2002-10-19 10:23:54'), +(5, '15:00', '15:00 BST', '5 years', '2003-10-19 10:23:54+01', '2003-10-19 10:23:54'), +(6, '15:00', '15:00 BST', '5 years', '2004-10-19 10:23:54+01', '2004-10-19 10:23:54'), +(7, '17:00', '17:00 BST', '7 years', '2005-10-19 10:23:54+01', '2005-10-19 10:23:54'), +(8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), +(9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), +(10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54'); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_time, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_time range between +-- '70 min' preceding and '2 hours' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_time, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_time desc range between +-- '70 min' preceding and '2 hours' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_timetz, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_timetz range between +-- '70 min' preceding and '2 hours' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_timetz, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_timetz desc range between +-- '70 min' preceding and '2 hours' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_interval, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_interval range between +-- '1 year' preceding and '1 year' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_interval, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_interval desc range between +-- '1 year' preceding and '1 year' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_timestamptz, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_timestamptz range between +-- '1 year' preceding and '1 year' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_timestamptz, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_timestamptz desc range between +-- '1 year' preceding and '1 year' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_timestamp, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_timestamp range between +-- '1 year' preceding and '1 year' following); + +-- [SPARK-28429] SQL Datetime util function being casted to double instead of timestamp +-- select id, f_timestamp, first(id) over w, last(id) over w +-- from datetimes +-- window w as (order by f_timestamp desc range between +-- '1 year' preceding and '1 year' following); + +-- RANGE offset PRECEDING/FOLLOWING error cases +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select sum(salary) over (order by enroll_date, salary range between '1 year' preceding and '2 years' following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select sum(salary) over (range between '1 year' preceding and '2 years' following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select sum(salary) over (order by depname range between '1 year' preceding and '2 years' following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select max(enroll_date) over (order by enroll_date range between 1 preceding and 2 following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select max(enroll_date) over (order by salary range between -1 preceding and 2 following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select max(enroll_date) over (order by salary range between 1 preceding and -2 following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select max(enroll_date) over (order by salary range between '1 year' preceding and '2 years' following +-- exclude ties), salary, enroll_date from empsalary; + +-- [SPARK-28428] Spark `exclude` always expecting `()` +-- select max(enroll_date) over (order by enroll_date range between '1 year' preceding and '-2 years' following +-- exclude ties), salary, enroll_date from empsalary; + +-- GROUPS tests + SELECT sum(unique1) over (order by four range between unbounded preceding and current row), unique1, four FROM tenk1 WHERE unique1 < 10; @@ -604,6 +828,8 @@ FROM tenk1 WHERE unique1 < 10; -- lag(salary) over(order by enroll_date range between 1 following and 3 following exclude group), -- salary, enroll_date from empsalary; +-- Show differences in offset interpretation between ROWS, RANGE, and GROUPS + WITH cte (x) AS ( SELECT * FROM range(1, 35, 2) ) @@ -649,14 +875,18 @@ SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); +-- with UNION + SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0; +-- check some degenerate cases + create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) -from t1 where f1 = f2; +from t1 where f1 = f2; -- error, must have order by -- Since EXPLAIN clause rely on host physical location, it is commented out -- explain @@ -697,11 +927,15 @@ select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2; +-- ordering by a non-integer constant is allowed + SELECT rank() OVER (ORDER BY length('abc')); +-- can't order by another window function -- [SPARK-28086] Adds `random()` to Spark -- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); +-- some other errors select * from (select row_number() over (order by salary) rn from empsalary) ss where rn < 10; @@ -730,12 +964,17 @@ where rn < 10; -- [SPARK-27951] ANSI SQL: NTH_VALUE function -- SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; +-- filter + -- [SPARK-28500] Adds support for `filter` clause -- SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( -- sum(salary) FILTER (WHERE enroll_date > '2007-01-01') -- ) -- FROM empsalary GROUP BY depname; +-- Test pushdown of quals into a subquery containing window functions + +-- pushdown is safe because all PARTITION BY clauses include depname: -- Since EXPLAIN clause rely on host physical location, it is commented out -- EXPLAIN -- SELECT * FROM @@ -745,6 +984,7 @@ where rn < 10; -- FROM empsalary) emp -- WHERE depname = 'sales'; +-- pushdown is unsafe because there's a PARTITION BY clause without depname: -- Since EXPLAIN clause rely on host physical location, it is commented out -- EXPLAIN -- SELECT * FROM @@ -754,6 +994,7 @@ where rn < 10; -- FROM empsalary) emp -- WHERE depname = 'sales'; +-- Test Sort node collapsing -- Since EXPLAIN clause rely on host physical location, it is commented out -- EXPLAIN -- SELECT * FROM @@ -763,6 +1004,7 @@ where rn < 10; -- FROM empsalary) emp -- WHERE depname = 'sales'; +-- Test Sort node reordering -- Since EXPLAIN clause rely on host physical location, it is commented out -- EXPLAIN -- SELECT @@ -770,6 +1012,14 @@ where rn < 10; -- lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) -- FROM empsalary; +-- cleanup +DROP TABLE empsalary; + +-- +-- Test various built-in aggregates that have moving-aggregate support +-- + +-- test inverse transition functions handle NULLs properly SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); @@ -893,11 +1143,24 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v); +-- ensure aggregate over numeric properly recovers from NaN values +-- [SPARK-27768] Infinity, -Infinity, NaN should be recognized in a case insensitive manner +-- SELECT a, b, +-- SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +-- FROM (VALUES(1,1),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b); + +-- It might be tempting for someone to add an inverse trans function for +-- float and double precision. This should not be done as it can give incorrect +-- results. This test should fail if anyone ever does this without thinking too +-- hard about it. +-- [SPARK-28516] adds `to_char` +-- SELECT to_char(SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING),'999999999999999999999D9') +-- FROM (VALUES(1,1e20),(2,1)) n(i,n); + -- [SPARK-27880] Implement boolean aggregates(BOOL_AND, BOOL_OR and EVERY) -- SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w -- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) -- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); -drop table empsalary; drop table t1; drop view int4_tbl; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 52e95fc96fcf8..849e43ae21b1c 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 141 +-- Number of queries: 156 -- !query 0 @@ -503,8 +503,8 @@ struct -- !query 30 SELECT sum(salary), -row_number() OVER (ORDER BY depname), -sum(sum(salary)) OVER (ORDER BY depname DESC) + row_number() OVER (ORDER BY depname), + sum(sum(salary)) OVER (ORDER BY depname DESC) FROM empsalary GROUP BY depname -- !query 30 schema struct @@ -601,29 +601,13 @@ struct -- !query 37 -select first(max(x)) over (), y - from (select unique1 as x, ten+four as y from tenk1) ss - group by y --- !query 37 schema -struct --- !query 37 output -9980 0 -9980 10 -9980 12 -9980 2 -9980 4 -9980 6 -9980 8 - - --- !query 38 SELECT four, ten, sum(ten) over (partition by four order by ten), last(ten) over (partition by four order by ten) FROM (select distinct ten, four from tenk1) ss --- !query 38 schema +-- !query 37 schema struct --- !query 38 output +-- !query 37 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -646,14 +630,14 @@ struct --- !query 39 output +-- !query 38 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -676,14 +660,14 @@ struct --- !query 40 output +-- !query 39 output 0 0 20 8 0 2 20 8 0 4 20 8 @@ -706,14 +690,14 @@ struct --- !query 41 output +-- !query 40 output 0 0 0 0 0 0 0 0 0 1 2 1 @@ -736,14 +720,14 @@ struct --- !query 42 output +-- !query 41 output 0 0 0 0 0 0 0 0 0 1 1 1 @@ -766,13 +750,13 @@ struct --- !query 43 output +-- !query 42 output 10 3 3 10 7 3 18 2 2 @@ -785,13 +769,13 @@ struct --- !query 44 output +-- !query 43 output 0 0 0 10 3 3 15 5 1 @@ -804,13 +788,13 @@ struct --- !query 45 output +-- !query 44 output 10 0 0 13 2 2 15 7 3 @@ -823,13 +807,13 @@ struct --- !query 46 output +-- !query 45 output 10 0 0 13 3 3 15 8 0 @@ -842,13 +826,13 @@ struct --- !query 47 output +-- !query 46 output 0 7 3 10 5 1 15 8 0 @@ -861,13 +845,13 @@ struct --- !query 48 output +-- !query 47 output 13 1 1 22 6 2 30 9 1 @@ -880,21 +864,21 @@ struct --- !query 49 output +-- !query 48 output --- !query 50 +-- !query 49 SELECT * FROM v_window --- !query 50 schema +-- !query 49 schema struct --- !query 50 output +-- !query 49 output 1 3 2 6 3 9 @@ -906,11 +890,11 @@ struct 9 17 --- !query 51 +-- !query 50 SELECT * FROM v_window --- !query 51 schema +-- !query 50 schema struct --- !query 51 output +-- !query 50 output 1 3 2 6 3 9 @@ -922,11 +906,11 @@ struct 9 17 --- !query 52 +-- !query 51 SELECT * FROM v_window --- !query 52 schema +-- !query 51 schema struct --- !query 52 output +-- !query 51 output 1 3 2 6 3 9 @@ -938,11 +922,11 @@ struct 9 17 --- !query 53 +-- !query 52 SELECT * FROM v_window --- !query 53 schema +-- !query 52 schema struct --- !query 53 output +-- !query 52 output 1 3 2 6 3 9 @@ -954,20 +938,20 @@ struct 9 17 --- !query 54 +-- !query 53 CREATE OR REPLACE TEMP VIEW v_window AS SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i --- !query 54 schema +-- !query 53 schema struct<> --- !query 54 output +-- !query 53 output --- !query 55 +-- !query 54 SELECT * FROM v_window --- !query 55 schema +-- !query 54 schema struct --- !query 55 output +-- !query 54 output 1 3 2 6 3 9 @@ -979,21 +963,21 @@ struct 9 17 --- !query 56 +-- !query 55 DROP VIEW v_window --- !query 56 schema +-- !query 55 schema struct<> --- !query 56 output +-- !query 55 output --- !query 57 +-- !query 56 SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 57 schema +-- !query 56 schema struct --- !query 57 output +-- !query 56 output 12 1 1 12 5 1 12 9 1 @@ -1006,13 +990,13 @@ NULL 4 0 NULL 8 0 --- !query 58 +-- !query 57 SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 58 schema +-- !query 57 schema struct --- !query 58 output +-- !query 57 output 10 2 2 10 6 2 18 1 1 @@ -1025,13 +1009,13 @@ NULL 3 3 NULL 7 3 --- !query 59 +-- !query 58 SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 59 schema +-- !query 58 schema struct --- !query 59 output +-- !query 58 output 10 3 3 10 7 3 12 4 0 @@ -1044,7 +1028,7 @@ struct --- !query 60 output +-- !query 59 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1065,7 +1049,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 61 +-- !query 60 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1075,9 +1059,9 @@ from union all select null, 43) ss window w as (order by ss.id asc nulls last range between 2 preceding and 2 following) --- !query 61 schema +-- !query 60 schema struct --- !query 61 output +-- !query 60 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1086,7 +1070,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 62 +-- !query 61 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1096,9 +1080,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls first range between 2 preceding and 2 following) --- !query 62 schema +-- !query 61 schema struct --- !query 62 output +-- !query 61 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1107,7 +1091,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 63 +-- !query 62 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1117,9 +1101,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls last range between 2 preceding and 2 following) --- !query 63 schema +-- !query 62 schema struct --- !query 63 output +-- !query 62 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1128,149 +1112,423 @@ NULL 42 42 43 NULL 43 42 43 --- !query 64 +-- !query 63 select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) from range(32764, 32766) x --- !query 64 schema +-- !query 63 schema struct --- !query 64 output +-- !query 63 output 32764 32765 32765 32765 --- !query 65 +-- !query 64 select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) from range(-32766, -32764) x --- !query 65 schema +-- !query 64 schema struct --- !query 65 output +-- !query 64 output -32765 -32766 -32766 -32766 --- !query 66 +-- !query 65 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x --- !query 66 schema +-- !query 65 schema struct --- !query 66 output +-- !query 65 output 2147483644 2147483645 2147483645 2147483645 --- !query 67 +-- !query 66 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x --- !query 67 schema +-- !query 66 schema struct --- !query 67 output +-- !query 66 output -2147483645 -2147483646 -2147483646 -2147483646 --- !query 68 +-- !query 67 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x --- !query 68 schema +-- !query 67 schema struct --- !query 68 output +-- !query 67 output 9223372036854775804 NULL 9223372036854775805 NULL --- !query 69 +-- !query 68 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x --- !query 69 schema +-- !query 68 schema struct --- !query 69 output +-- !query 68 output -9223372036854775805 NULL -9223372036854775806 NULL +-- !query 69 +create table numerics ( + id int, + f_float4 float, + f_float8 float, + f_numeric int +) using parquet +-- !query 69 schema +struct<> +-- !query 69 output + + + -- !query 70 -SELECT sum(unique1) over (order by four range between unbounded preceding and current row), -unique1, four -FROM tenk1 WHERE unique1 < 10 +insert into numerics values +(1, -3, -3, -3), +(2, -1, -1, -1), +(3, 0, 0, 0), +(4, 1.1, 1.1, 1.1), +(5, 1.12, 1.12, 1.12), +(6, 2, 2, 2), +(7, 100, 100, 100) -- !query 70 schema -struct +struct<> -- !query 70 output -12 0 0 -12 4 0 -12 8 0 -27 1 1 -27 5 1 -27 9 1 -35 2 2 -35 6 2 -45 3 3 -45 7 3 + -- !query 71 -SELECT sum(unique1) over (order by four range between unbounded preceding and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1 following) -- !query 71 schema -struct +struct -- !query 71 output -45 0 0 -45 1 1 -45 2 2 -45 3 3 -45 4 0 -45 5 1 -45 6 2 -45 7 3 -45 8 0 -45 9 1 +1 -3.0 1 1 +2 -1.0 2 3 +3 0.0 2 3 +4 1.1 4 6 +5 1.12 4 6 +6 2.0 4 6 +7 100.0 7 7 -- !query 72 -SELECT sum(unique1) over (order by four range between current row and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1.1 following) -- !query 72 schema -struct +struct -- !query 72 output -10 3 3 -10 7 3 -18 2 2 -18 6 2 -33 1 1 -33 5 1 -33 9 1 -45 0 0 -45 4 0 -45 8 0 +1 -3.0 1 1 +2 -1.0 2 3 +3 0.0 2 4 +4 1.1 4 6 +5 1.12 4 6 +6 2.0 4 6 +7 100.0 7 7 -- !query 73 -SELECT sum(unique1) over (order by four range between 1 preceding and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' preceding and 'inf' following) -- !query 73 schema -struct +struct -- !query 73 output -18 3 3 -18 7 3 -33 2 2 -33 6 2 -45 0 0 -45 1 1 +1 -3.0 NULL NULL +2 -1.0 NULL NULL +3 0.0 NULL NULL +4 1.1 NULL NULL +5 1.12 NULL NULL +6 2.0 NULL NULL +7 100.0 NULL NULL + + +-- !query 74 +select id, f_float4, first(id) over w, last(id) over w +from numerics +window w as (order by f_float4 range between + 1.1 preceding and 'NaN' following) +-- !query 74 schema +struct +-- !query 74 output +1 -3.0 1 7 +2 -1.0 2 7 +3 0.0 2 7 +4 1.1 3 7 +5 1.12 4 7 +6 2.0 4 7 +7 100.0 7 7 + + +-- !query 75 +-- error, NaN disallowed + +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1 following) +-- !query 75 schema +struct +-- !query 75 output +1 -3.0 1 1 +2 -1.0 2 3 +3 0.0 2 3 +4 1.1 4 6 +5 1.12 4 6 +6 2.0 4 6 +7 100.0 7 7 + + +-- !query 76 +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1.1 following) +-- !query 76 schema +struct +-- !query 76 output +1 -3.0 1 1 +2 -1.0 2 3 +3 0.0 2 4 +4 1.1 4 6 +5 1.12 4 6 +6 2.0 4 6 +7 100.0 7 7 + + +-- !query 77 +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' preceding and 'inf' following) +-- !query 77 schema +struct +-- !query 77 output +1 -3.0 NULL NULL +2 -1.0 NULL NULL +3 0.0 NULL NULL +4 1.1 NULL NULL +5 1.12 NULL NULL +6 2.0 NULL NULL +7 100.0 NULL NULL + + +-- !query 78 +select id, f_float8, first(id) over w, last(id) over w +from numerics +window w as (order by f_float8 range between + 1.1 preceding and 'NaN' following) +-- !query 78 schema +struct +-- !query 78 output +1 -3.0 1 7 +2 -1.0 2 7 +3 0.0 2 7 +4 1.1 3 7 +5 1.12 4 7 +6 2.0 4 7 +7 100.0 7 7 + + +-- !query 79 +-- error, NaN disallowed + +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1 following) +-- !query 79 schema +struct +-- !query 79 output +1 -3 1 1 +2 -1 2 3 +3 0 2 5 +4 1 3 6 +5 1 3 6 +6 2 4 6 +7 100 7 7 + + +-- !query 80 +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1 following) +-- !query 80 schema +struct +-- !query 80 output +1 -3 1 1 +2 -1 2 3 +3 0 2 5 +4 1 3 6 +5 1 3 6 +6 2 4 6 +7 100 7 7 + + +-- !query 81 +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1 following) +-- !query 81 schema +struct +-- !query 81 output +1 -3 1 1 +2 -1 2 3 +3 0 2 5 +4 1 3 6 +5 1 3 6 +6 2 4 6 +7 100 7 7 + + +-- !query 82 +-- currently unsupported + +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1.1 preceding and 'NaN' following) +-- !query 82 schema +struct +-- !query 82 output +1 -3 NULL NULL +2 -1 NULL NULL +3 0 NULL NULL +4 1 NULL NULL +5 1 NULL NULL +6 2 NULL NULL +7 100 NULL NULL + + +-- !query 83 +-- error, NaN disallowed + + +create table datetimes ( + id int, + f_time timestamp, + f_timetz timestamp, + f_interval timestamp, + f_timestamptz timestamp, + f_timestamp timestamp +) using parquet +-- !query 83 schema +struct<> +-- !query 83 output + + + +-- !query 84 +insert into datetimes values +(1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), +(2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(3, '13:00', '13:00 BST', '3 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(4, '14:00', '14:00 BST', '4 years', '2002-10-19 10:23:54+01', '2002-10-19 10:23:54'), +(5, '15:00', '15:00 BST', '5 years', '2003-10-19 10:23:54+01', '2003-10-19 10:23:54'), +(6, '15:00', '15:00 BST', '5 years', '2004-10-19 10:23:54+01', '2004-10-19 10:23:54'), +(7, '17:00', '17:00 BST', '7 years', '2005-10-19 10:23:54+01', '2005-10-19 10:23:54'), +(8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), +(9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), +(10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54') +-- !query 84 schema +struct<> +-- !query 84 output + + + +-- !query 85 +SELECT sum(unique1) over (order by four range between unbounded preceding and current row), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 85 schema +struct +-- !query 85 output +12 0 0 +12 4 0 +12 8 0 +27 1 1 +27 5 1 +27 9 1 +35 2 2 +35 6 2 +45 3 3 +45 7 3 + + +-- !query 86 +SELECT sum(unique1) over (order by four range between unbounded preceding and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 86 schema +struct +-- !query 86 output +45 0 0 +45 1 1 +45 2 2 +45 3 3 45 4 0 45 5 1 +45 6 2 +45 7 3 45 8 0 45 9 1 --- !query 74 +-- !query 87 +SELECT sum(unique1) over (order by four range between current row and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 87 schema +struct +-- !query 87 output +10 3 3 +10 7 3 +18 2 2 +18 6 2 +33 1 1 +33 5 1 +33 9 1 +45 0 0 +45 4 0 +45 8 0 + + +-- !query 88 +SELECT sum(unique1) over (order by four range between 1 preceding and unbounded following), +unique1, four +FROM tenk1 WHERE unique1 < 10 +-- !query 88 schema +struct +-- !query 88 output +18 3 3 +18 7 3 +33 2 2 +33 6 2 +45 0 0 +45 1 1 +45 4 0 +45 5 1 +45 8 0 +45 9 1 + + +-- !query 89 SELECT sum(unique1) over (order by four range between 1 following and unbounded following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 74 schema +-- !query 89 schema struct --- !query 74 output +-- !query 89 output 10 2 2 10 6 2 18 1 1 @@ -1283,13 +1541,13 @@ NULL 3 3 NULL 7 3 --- !query 75 +-- !query 90 SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 75 schema +-- !query 90 schema struct --- !query 75 output +-- !query 90 output 35 0 0 35 4 0 35 8 0 @@ -1302,13 +1560,13 @@ struct --- !query 76 output +-- !query 91 output 12 1 1 12 5 1 12 9 1 @@ -1321,13 +1579,13 @@ NULL 4 0 NULL 8 0 --- !query 77 +-- !query 92 SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 77 schema +-- !query 92 schema struct --- !query 77 output +-- !query 92 output 10 3 3 10 7 3 12 0 0 @@ -1340,13 +1598,13 @@ struct --- !query 78 output +-- !query 93 output 0 0 0 0 1 1 1 1 2 2 2 2 @@ -1359,16 +1617,16 @@ struct --- !query 79 output +-- !query 94 output 1 4 11 33 13 39 @@ -1388,16 +1646,16 @@ struct --- !query 80 output +-- !query 95 output 1 1 11 11 13 13 @@ -1417,16 +1675,16 @@ struct --- !query 81 output +-- !query 96 output 1 1 11 11 13 13 @@ -1446,7 +1704,7 @@ struct --- !query 82 output +-- !query 97 output 1 2 1 3 1 7 @@ -1484,7 +1742,7 @@ struct --- !query 83 output +-- !query 98 output 1 3 1 3 1 3 @@ -1522,7 +1780,7 @@ struct --- !query 84 output +-- !query 99 output 1 3 1 3 1 3 @@ -1560,122 +1818,125 @@ struct --- !query 85 output +-- !query 100 output --- !query 86 +-- !query 101 create table t1 (f1 int, f2 int) using parquet --- !query 86 schema +-- !query 101 schema struct<> --- !query 86 output +-- !query 101 output --- !query 87 +-- !query 102 insert into t1 values (1,1),(1,2),(2,2) --- !query 87 schema +-- !query 102 schema struct<> --- !query 87 output +-- !query 102 output --- !query 88 +-- !query 103 select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 88 schema +-- !query 103 schema struct --- !query 88 output +-- !query 103 output 1 1 2 2 --- !query 89 +-- !query 104 +-- error, must have order by + + select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 89 schema +-- !query 104 schema struct --- !query 89 output +-- !query 104 output 1 NULL 2 NULL --- !query 90 +-- !query 105 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 90 schema +-- !query 105 schema struct --- !query 90 output +-- !query 105 output 1 NULL 2 NULL --- !query 91 +-- !query 106 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 91 schema +-- !query 106 schema struct --- !query 91 output +-- !query 106 output 1 1 2 2 --- !query 92 +-- !query 107 select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 92 schema +-- !query 107 schema struct --- !query 92 output +-- !query 107 output 1 1 2 2 --- !query 93 +-- !query 108 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 93 schema +-- !query 108 schema struct --- !query 93 output +-- !query 108 output 1 NULL 2 NULL --- !query 94 +-- !query 109 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 94 schema +-- !query 109 schema struct --- !query 94 output +-- !query 109 output 1 NULL 2 NULL --- !query 95 +-- !query 110 SELECT rank() OVER (ORDER BY length('abc')) --- !query 95 schema +-- !query 110 schema struct --- !query 95 output +-- !query 110 output 1 --- !query 96 +-- !query 111 select * from (select row_number() over (order by salary) rn from empsalary) ss where rn < 10 --- !query 96 schema +-- !query 111 schema struct --- !query 96 output +-- !query 111 output 1 2 3 @@ -1687,179 +1948,187 @@ struct 9 --- !query 97 +-- !query 112 +DROP TABLE empsalary +-- !query 112 schema +struct<> +-- !query 112 output + + + +-- !query 113 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 97 schema +-- !query 113 schema struct --- !query 97 output +-- !query 113 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 98 +-- !query 114 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 98 schema +-- !query 114 schema struct --- !query 98 output +-- !query 114 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 99 +-- !query 115 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 99 schema +-- !query 115 schema struct --- !query 99 output +-- !query 115 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 100 +-- !query 116 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 100 schema +-- !query 116 schema struct --- !query 100 output +-- !query 116 output 1 2 2 2.5 3 NULL 4 NULL --- !query 101 +-- !query 117 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 101 schema +-- !query 117 schema struct --- !query 101 output +-- !query 117 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 102 +-- !query 118 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 102 schema +-- !query 118 schema struct --- !query 102 output +-- !query 118 output 1 3 2 2 3 NULL 4 NULL --- !query 103 +-- !query 119 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 103 schema +-- !query 119 schema struct --- !query 103 output +-- !query 119 output 1 3 2 2 3 NULL 4 NULL --- !query 104 +-- !query 120 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 104 schema +-- !query 120 schema struct --- !query 104 output +-- !query 120 output 1 3 2 2 3 NULL 4 NULL --- !query 105 +-- !query 121 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 105 schema +-- !query 121 schema struct --- !query 105 output +-- !query 121 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 106 +-- !query 122 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 106 schema +-- !query 122 schema struct --- !query 106 output +-- !query 122 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 107 +-- !query 123 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 107 schema +-- !query 123 schema struct --- !query 107 output +-- !query 123 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 108 +-- !query 124 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 108 schema +-- !query 124 schema struct --- !query 108 output +-- !query 124 output 3 5 6.01 --- !query 109 +-- !query 125 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 109 schema +-- !query 125 schema struct --- !query 109 output +-- !query 125 output 1 2 2 1 3 0 4 0 --- !query 110 +-- !query 126 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 110 schema +-- !query 126 schema struct --- !query 110 output +-- !query 126 output 1 4 2 3 3 2 4 1 --- !query 111 +-- !query 127 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 111 schema +-- !query 127 schema struct --- !query 111 output +-- !query 127 output 0.0 11266.666666666666 13868.750000000002 @@ -1867,12 +2136,12 @@ struct --- !query 112 output +-- !query 128 output 0.0 11266.666666666666 13868.750000000002 @@ -1880,12 +2149,12 @@ struct --- !query 113 output +-- !query 129 output 0.0 11266.666666666666 13868.750000000002 @@ -1893,12 +2162,12 @@ struct --- !query 114 output +-- !query 130 output 0.0 11266.666666666666 13868.750000000002 @@ -1906,12 +2175,12 @@ struct --- !query 115 output +-- !query 131 output 16900.0 18491.666666666668 27129.999999999996 @@ -1919,12 +2188,12 @@ struct --- !query 116 output +-- !query 132 output 16900.0 18491.666666666668 27129.999999999996 @@ -1932,12 +2201,12 @@ struct --- !query 117 output +-- !query 133 output 16900.0 18491.666666666668 27129.999999999996 @@ -1945,12 +2214,12 @@ struct --- !query 118 output +-- !query 134 output 16900.0 18491.666666666668 27129.999999999996 @@ -1958,12 +2227,12 @@ struct --- !query 119 output +-- !query 135 output 16900.0 18491.666666666668 27129.999999999996 @@ -1971,12 +2240,12 @@ struct --- !query 120 output +-- !query 136 output 16900.0 18491.666666666668 27129.999999999996 @@ -1984,12 +2253,12 @@ struct --- !query 121 output +-- !query 137 output 16900.0 18491.666666666668 27129.999999999996 @@ -1997,12 +2266,12 @@ struct --- !query 122 output +-- !query 138 output 16900.0 18491.666666666668 27129.999999999996 @@ -2010,12 +2279,12 @@ struct --- !query 123 output +-- !query 139 output 0.0 106.14455552060438 117.76565713313879 @@ -2024,12 +2293,12 @@ struct --- !query 124 output +-- !query 140 output 0.0 106.14455552060438 117.76565713313879 @@ -2038,12 +2307,12 @@ struct --- !query 125 output +-- !query 141 output 0.0 106.14455552060438 117.76565713313879 @@ -2052,12 +2321,12 @@ struct --- !query 126 output +-- !query 142 output 0.0 106.14455552060438 117.76565713313879 @@ -2066,12 +2335,12 @@ struct --- !query 127 output +-- !query 143 output 130.0 135.9840676942217 164.7118696390761 @@ -2080,12 +2349,12 @@ struct --- !query 128 output +-- !query 144 output 130.0 135.9840676942217 164.7118696390761 @@ -2094,12 +2363,12 @@ struct --- !query 129 output +-- !query 145 output 130.0 135.9840676942217 164.7118696390761 @@ -2108,12 +2377,12 @@ struct --- !query 130 output +-- !query 146 output 130.0 135.9840676942217 164.7118696390761 @@ -2122,12 +2391,12 @@ struct --- !query 131 output +-- !query 147 output 130.0 135.9840676942217 164.7118696390761 @@ -2136,12 +2405,12 @@ struct --- !query 132 output +-- !query 148 output 130.0 135.9840676942217 164.7118696390761 @@ -2150,12 +2419,12 @@ struct --- !query 133 output +-- !query 149 output 130.0 135.9840676942217 164.7118696390761 @@ -2164,12 +2433,12 @@ struct --- !query 134 output +-- !query 150 output 130.0 135.9840676942217 164.7118696390761 @@ -2178,61 +2447,53 @@ struct --- !query 135 output +-- !query 151 output 1 1 2 2 3 NULL 4 NULL --- !query 136 +-- !query 152 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 136 schema +-- !query 152 schema struct --- !query 136 output +-- !query 152 output 1 3 2 2 3 NULL 4 NULL --- !query 137 +-- !query 153 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 137 schema +-- !query 153 schema struct --- !query 137 output +-- !query 153 output 1 3 2 6 3 9 4 7 --- !query 138 -drop table empsalary --- !query 138 schema -struct<> --- !query 138 output - - - --- !query 139 +-- !query 154 drop table t1 --- !query 139 schema +-- !query 154 schema struct<> --- !query 139 output +-- !query 154 output --- !query 140 +-- !query 155 drop view int4_tbl --- !query 140 schema +-- !query 155 schema struct<> --- !query 140 output +-- !query 155 output From 4ccbe5022079c8e476ca1126e08a9d51d137804b Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 29 Jul 2019 12:03:00 -0300 Subject: [PATCH 15/25] adds drop table numerics Signed-off-by: DylanGuedes --- sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index e6b185cb6d06d..c7438682bcdc8 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -1162,5 +1162,6 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) -- FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) -- WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING); +drop table numerics; drop table t1; drop view int4_tbl; From 76d2820e2b7f77d372e0727eb1a82854aa902d9c Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 29 Jul 2019 14:47:40 -0300 Subject: [PATCH 16/25] update golden file Signed-off-by: DylanGuedes --- .../sql-tests/results/pgSQL/window.sql.out | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 849e43ae21b1c..1f2128df4574b 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 156 +-- Number of queries: 157 -- !query 0 @@ -2484,7 +2484,7 @@ struct -- !query 154 output @@ -2492,8 +2492,16 @@ struct<> -- !query 155 -drop view int4_tbl +drop table t1 -- !query 155 schema struct<> -- !query 155 output + + +-- !query 156 +drop view int4_tbl +-- !query 156 schema +struct<> +-- !query 156 output + From bea5ba6e577a47f4c57b845de8b54507142e2f0b Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Tue, 30 Jul 2019 09:02:19 -0300 Subject: [PATCH 17/25] temporarily turns off ansi Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 22 +- .../sql-tests/results/pgSQL/window.sql.out | 793 ++++++++++-------- 2 files changed, 436 insertions(+), 379 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index c7438682bcdc8..86f78b7f4dd72 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -133,14 +133,16 @@ SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC); -- strict aggs --- no viable alternative at input 'year' --- SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( --- SELECT *, --- CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(year FROM enroll_date) END * 500 AS bonus, --- CASE WHEN --- AVG(salary) OVER (PARTITION BY depname) < salary --- THEN 200 END AS depadj FROM empsalary --- )s; +-- Temporarily turns off the ANSI mode because of compatibility issues between keywords +SET spark.sql.parser.ansi.enabled=false; +SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( +SELECT *, + CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(year FROM enroll_date) END * 500 AS bonus, + CASE WHEN + AVG(salary) OVER (PARTITION BY depname) < salary + THEN 200 END AS depadj FROM empsalary + )s; +SET spark.sql.parser.ansi.enabled=true; create temporary view int4_tbl as select * from values (0), @@ -932,8 +934,7 @@ from t1 where f1 = f2; SELECT rank() OVER (ORDER BY length('abc')); -- can't order by another window function --- [SPARK-28086] Adds `random()` to Spark --- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); +SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); -- some other errors select * from @@ -1165,3 +1166,4 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) drop table numerics; drop table t1; drop view int4_tbl; +drop table datetimes; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 1f2128df4574b..01c2759b88589 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 157 +-- Number of queries: 162 -- !query 0 @@ -558,6 +558,45 @@ struct +-- !query 34 output +spark.sql.parser.ansi.enabled false + + +-- !query 35 +SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( +SELECT *, + CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(year FROM enroll_date) END * 500 AS bonus, + CASE WHEN + AVG(salary) OVER (PARTITION BY depname) < salary + THEN 200 END AS depadj FROM empsalary + )s +-- !query 35 schema +struct +-- !query 35 output +1 sales 5000 1000 200 1000 200 +10 develop 5200 500 200 500 200 +11 develop 5200 500 200 500 200 +2 personnel 3900 1000 200 1000 200 +3 sales 4800 500 NULL 500 200 +4 sales 4800 500 NULL 500 200 +5 personnel 3500 500 NULL 500 200 +7 develop 4200 NULL NULL 500 200 +8 develop 6000 1000 200 500 200 +9 develop 4500 NULL NULL 500 200 + + +-- !query 36 +SET spark.sql.parser.ansi.enabled=true +-- !query 36 schema +struct +-- !query 36 output +spark.sql.parser.ansi.enabled true + + +-- !query 37 create temporary view int4_tbl as select * from values (0), (123456), @@ -565,29 +604,29 @@ create temporary view int4_tbl as select * from values (2147483647), (-2147483647) as int4_tbl(f1) --- !query 34 schema +-- !query 37 schema struct<> --- !query 34 output +-- !query 37 output --- !query 35 +-- !query 38 SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 --- !query 35 schema +-- !query 38 schema struct --- !query 35 output +-- !query 38 output 0 --- !query 36 +-- !query 39 select ten, sum(unique1) + sum(unique2) as res, rank() over (order by sum(unique1) + sum(unique2)) as rank from tenk1 group by ten order by ten --- !query 36 schema +-- !query 39 schema struct --- !query 36 output +-- !query 39 output 0 9976146 4 1 10114187 9 2 10059554 8 @@ -600,14 +639,14 @@ struct 9 10040184 7 --- !query 37 +-- !query 40 SELECT four, ten, sum(ten) over (partition by four order by ten), last(ten) over (partition by four order by ten) FROM (select distinct ten, four from tenk1) ss --- !query 37 schema +-- !query 40 schema struct --- !query 37 output +-- !query 40 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -630,14 +669,14 @@ struct --- !query 38 output +-- !query 41 output 0 0 0 0 0 2 2 2 0 4 6 4 @@ -660,14 +699,14 @@ struct --- !query 39 output +-- !query 42 output 0 0 20 8 0 2 20 8 0 4 20 8 @@ -690,14 +729,14 @@ struct --- !query 40 output +-- !query 43 output 0 0 0 0 0 0 0 0 0 1 2 1 @@ -720,14 +759,14 @@ struct --- !query 41 output +-- !query 44 output 0 0 0 0 0 0 0 0 0 1 1 1 @@ -750,13 +789,13 @@ struct --- !query 42 output +-- !query 45 output 10 3 3 10 7 3 18 2 2 @@ -769,13 +808,13 @@ struct --- !query 43 output +-- !query 46 output 0 0 0 10 3 3 15 5 1 @@ -788,13 +827,13 @@ struct --- !query 44 output +-- !query 47 output 10 0 0 13 2 2 15 7 3 @@ -807,13 +846,13 @@ struct --- !query 45 output +-- !query 48 output 10 0 0 13 3 3 15 8 0 @@ -826,13 +865,13 @@ struct --- !query 46 output +-- !query 49 output 0 7 3 10 5 1 15 8 0 @@ -845,13 +884,13 @@ struct --- !query 47 output +-- !query 50 output 13 1 1 22 6 2 30 9 1 @@ -864,21 +903,21 @@ struct --- !query 48 output +-- !query 51 output --- !query 49 +-- !query 52 SELECT * FROM v_window --- !query 49 schema +-- !query 52 schema struct --- !query 49 output +-- !query 52 output 1 3 2 6 3 9 @@ -890,11 +929,11 @@ struct 9 17 --- !query 50 +-- !query 53 SELECT * FROM v_window --- !query 50 schema +-- !query 53 schema struct --- !query 50 output +-- !query 53 output 1 3 2 6 3 9 @@ -906,11 +945,11 @@ struct 9 17 --- !query 51 +-- !query 54 SELECT * FROM v_window --- !query 51 schema +-- !query 54 schema struct --- !query 51 output +-- !query 54 output 1 3 2 6 3 9 @@ -922,11 +961,11 @@ struct 9 17 --- !query 52 +-- !query 55 SELECT * FROM v_window --- !query 52 schema +-- !query 55 schema struct --- !query 52 output +-- !query 55 output 1 3 2 6 3 9 @@ -938,20 +977,20 @@ struct 9 17 --- !query 53 +-- !query 56 CREATE OR REPLACE TEMP VIEW v_window AS SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i --- !query 53 schema +-- !query 56 schema struct<> --- !query 53 output +-- !query 56 output --- !query 54 +-- !query 57 SELECT * FROM v_window --- !query 54 schema +-- !query 57 schema struct --- !query 54 output +-- !query 57 output 1 3 2 6 3 9 @@ -963,21 +1002,21 @@ struct 9 17 --- !query 55 +-- !query 58 DROP VIEW v_window --- !query 55 schema +-- !query 58 schema struct<> --- !query 55 output +-- !query 58 output --- !query 56 +-- !query 59 SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 56 schema +-- !query 59 schema struct --- !query 56 output +-- !query 59 output 12 1 1 12 5 1 12 9 1 @@ -990,13 +1029,13 @@ NULL 4 0 NULL 8 0 --- !query 57 +-- !query 60 SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 57 schema +-- !query 60 schema struct --- !query 57 output +-- !query 60 output 10 2 2 10 6 2 18 1 1 @@ -1009,13 +1048,13 @@ NULL 3 3 NULL 7 3 --- !query 58 +-- !query 61 SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 58 schema +-- !query 61 schema struct --- !query 58 output +-- !query 61 output 10 3 3 10 7 3 12 4 0 @@ -1028,7 +1067,7 @@ struct --- !query 59 output +-- !query 62 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1049,7 +1088,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 60 +-- !query 63 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1059,9 +1098,9 @@ from union all select null, 43) ss window w as (order by ss.id asc nulls last range between 2 preceding and 2 following) --- !query 60 schema +-- !query 63 schema struct --- !query 60 output +-- !query 63 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1070,7 +1109,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 61 +-- !query 64 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1080,9 +1119,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls first range between 2 preceding and 2 following) --- !query 61 schema +-- !query 64 schema struct --- !query 61 output +-- !query 64 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1091,7 +1130,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 62 +-- !query 65 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1101,9 +1140,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls last range between 2 preceding and 2 following) --- !query 62 schema +-- !query 65 schema struct --- !query 62 output +-- !query 65 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1112,80 +1151,80 @@ NULL 42 42 43 NULL 43 42 43 --- !query 63 +-- !query 66 select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) from range(32764, 32766) x --- !query 63 schema +-- !query 66 schema struct --- !query 63 output +-- !query 66 output 32764 32765 32765 32765 --- !query 64 +-- !query 67 select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) from range(-32766, -32764) x --- !query 64 schema +-- !query 67 schema struct --- !query 64 output +-- !query 67 output -32765 -32766 -32766 -32766 --- !query 65 +-- !query 68 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x --- !query 65 schema +-- !query 68 schema struct --- !query 65 output +-- !query 68 output 2147483644 2147483645 2147483645 2147483645 --- !query 66 +-- !query 69 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x --- !query 66 schema +-- !query 69 schema struct --- !query 66 output +-- !query 69 output -2147483645 -2147483646 -2147483646 -2147483646 --- !query 67 +-- !query 70 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x --- !query 67 schema +-- !query 70 schema struct --- !query 67 output +-- !query 70 output 9223372036854775804 NULL 9223372036854775805 NULL --- !query 68 +-- !query 71 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x --- !query 68 schema +-- !query 71 schema struct --- !query 68 output +-- !query 71 output -9223372036854775805 NULL -9223372036854775806 NULL --- !query 69 +-- !query 72 create table numerics ( id int, f_float4 float, f_float8 float, f_numeric int ) using parquet --- !query 69 schema +-- !query 72 schema struct<> --- !query 69 output +-- !query 72 output --- !query 70 +-- !query 73 insert into numerics values (1, -3, -3, -3), (2, -1, -1, -1), @@ -1194,20 +1233,20 @@ insert into numerics values (5, 1.12, 1.12, 1.12), (6, 2, 2, 2), (7, 100, 100, 100) --- !query 70 schema +-- !query 73 schema struct<> --- !query 70 output +-- !query 73 output --- !query 71 +-- !query 74 select id, f_float4, first(id) over w, last(id) over w from numerics window w as (order by f_float4 range between 1 preceding and 1 following) --- !query 71 schema +-- !query 74 schema struct --- !query 71 output +-- !query 74 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 3 @@ -1217,14 +1256,14 @@ struct --- !query 72 output +-- !query 75 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 4 @@ -1234,14 +1273,14 @@ struct --- !query 73 output +-- !query 76 output 1 -3.0 NULL NULL 2 -1.0 NULL NULL 3 0.0 NULL NULL @@ -1251,14 +1290,14 @@ struct --- !query 74 output +-- !query 77 output 1 -3.0 1 7 2 -1.0 2 7 3 0.0 2 7 @@ -1268,16 +1307,16 @@ struct --- !query 75 output +-- !query 78 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 3 @@ -1287,14 +1326,14 @@ struct --- !query 76 output +-- !query 79 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 4 @@ -1304,14 +1343,14 @@ struct --- !query 77 output +-- !query 80 output 1 -3.0 NULL NULL 2 -1.0 NULL NULL 3 0.0 NULL NULL @@ -1321,14 +1360,14 @@ struct --- !query 78 output +-- !query 81 output 1 -3.0 1 7 2 -1.0 2 7 3 0.0 2 7 @@ -1338,16 +1377,16 @@ struct --- !query 79 output +-- !query 82 output 1 -3 1 1 2 -1 2 3 3 0 2 5 @@ -1357,14 +1396,14 @@ struct --- !query 80 output +-- !query 83 output 1 -3 1 1 2 -1 2 3 3 0 2 5 @@ -1374,14 +1413,14 @@ struct --- !query 81 output +-- !query 84 output 1 -3 1 1 2 -1 2 3 3 0 2 5 @@ -1391,16 +1430,16 @@ struct --- !query 82 output +-- !query 85 output 1 -3 NULL NULL 2 -1 NULL NULL 3 0 NULL NULL @@ -1410,7 +1449,7 @@ struct --- !query 83 output +-- !query 86 output --- !query 84 +-- !query 87 insert into datetimes values (1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), (2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), @@ -1440,19 +1479,19 @@ insert into datetimes values (8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), (9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), (10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54') --- !query 84 schema +-- !query 87 schema struct<> --- !query 84 output +-- !query 87 output --- !query 85 +-- !query 88 SELECT sum(unique1) over (order by four range between unbounded preceding and current row), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 85 schema +-- !query 88 schema struct --- !query 85 output +-- !query 88 output 12 0 0 12 4 0 12 8 0 @@ -1465,13 +1504,13 @@ struct --- !query 86 output +-- !query 89 output 45 0 0 45 1 1 45 2 2 @@ -1484,13 +1523,13 @@ struct --- !query 87 output +-- !query 90 output 10 3 3 10 7 3 18 2 2 @@ -1503,13 +1542,13 @@ struct --- !query 88 output +-- !query 91 output 18 3 3 18 7 3 33 2 2 @@ -1522,13 +1561,13 @@ struct --- !query 89 output +-- !query 92 output 10 2 2 10 6 2 18 1 1 @@ -1541,13 +1580,13 @@ NULL 3 3 NULL 7 3 --- !query 90 +-- !query 93 SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 90 schema +-- !query 93 schema struct --- !query 90 output +-- !query 93 output 35 0 0 35 4 0 35 8 0 @@ -1560,13 +1599,13 @@ struct --- !query 91 output +-- !query 94 output 12 1 1 12 5 1 12 9 1 @@ -1579,13 +1618,13 @@ NULL 4 0 NULL 8 0 --- !query 92 +-- !query 95 SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 92 schema +-- !query 95 schema struct --- !query 92 output +-- !query 95 output 10 3 3 10 7 3 12 0 0 @@ -1598,13 +1637,13 @@ struct --- !query 93 output +-- !query 96 output 0 0 0 0 1 1 1 1 2 2 2 2 @@ -1617,16 +1656,16 @@ struct --- !query 94 output +-- !query 97 output 1 4 11 33 13 39 @@ -1646,16 +1685,16 @@ struct --- !query 95 output +-- !query 98 output 1 1 11 11 13 13 @@ -1675,16 +1714,16 @@ struct --- !query 96 output +-- !query 99 output 1 1 11 11 13 13 @@ -1704,7 +1743,7 @@ struct --- !query 97 output +-- !query 100 output 1 2 1 3 1 7 @@ -1742,7 +1781,7 @@ struct --- !query 98 output +-- !query 101 output 1 3 1 3 1 3 @@ -1780,7 +1819,7 @@ struct --- !query 99 output +-- !query 102 output 1 3 1 3 1 3 @@ -1818,125 +1857,133 @@ struct --- !query 100 output +-- !query 103 output --- !query 101 +-- !query 104 create table t1 (f1 int, f2 int) using parquet --- !query 101 schema +-- !query 104 schema struct<> --- !query 101 output +-- !query 104 output --- !query 102 +-- !query 105 insert into t1 values (1,1),(1,2),(2,2) --- !query 102 schema +-- !query 105 schema struct<> --- !query 102 output +-- !query 105 output --- !query 103 +-- !query 106 select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 103 schema +-- !query 106 schema struct --- !query 103 output +-- !query 106 output 1 1 2 2 --- !query 104 +-- !query 107 -- error, must have order by select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 104 schema +-- !query 107 schema struct --- !query 104 output +-- !query 107 output 1 NULL 2 NULL --- !query 105 +-- !query 108 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 105 schema +-- !query 108 schema struct --- !query 105 output +-- !query 108 output 1 NULL 2 NULL --- !query 106 +-- !query 109 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 106 schema +-- !query 109 schema struct --- !query 106 output +-- !query 109 output 1 1 2 2 --- !query 107 +-- !query 110 select f1, sum(f1) over (partition by f1 order by f2 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 107 schema +-- !query 110 schema struct --- !query 107 output +-- !query 110 output 1 1 2 2 --- !query 108 +-- !query 111 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 108 schema +-- !query 111 schema struct --- !query 108 output +-- !query 111 output 1 NULL 2 NULL --- !query 109 +-- !query 112 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 109 schema +-- !query 112 schema struct --- !query 109 output +-- !query 112 output 1 NULL 2 NULL --- !query 110 +-- !query 113 SELECT rank() OVER (ORDER BY length('abc')) --- !query 110 schema +-- !query 113 schema struct --- !query 110 output +-- !query 113 output 1 --- !query 111 +-- !query 114 +SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())) +-- !query 114 schema +struct +-- !query 114 output +1 + + +-- !query 115 select * from (select row_number() over (order by salary) rn from empsalary) ss where rn < 10 --- !query 111 schema +-- !query 115 schema struct --- !query 111 output +-- !query 115 output 1 2 3 @@ -1948,187 +1995,187 @@ struct 9 --- !query 112 +-- !query 116 DROP TABLE empsalary --- !query 112 schema +-- !query 116 schema struct<> --- !query 112 output +-- !query 116 output --- !query 113 +-- !query 117 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 113 schema +-- !query 117 schema struct --- !query 113 output +-- !query 117 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 114 +-- !query 118 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 114 schema +-- !query 118 schema struct --- !query 114 output +-- !query 118 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 115 +-- !query 119 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 115 schema +-- !query 119 schema struct --- !query 115 output +-- !query 119 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 116 +-- !query 120 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 116 schema +-- !query 120 schema struct --- !query 116 output +-- !query 120 output 1 2 2 2.5 3 NULL 4 NULL --- !query 117 +-- !query 121 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 117 schema +-- !query 121 schema struct --- !query 117 output +-- !query 121 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 118 +-- !query 122 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 118 schema +-- !query 122 schema struct --- !query 118 output +-- !query 122 output 1 3 2 2 3 NULL 4 NULL --- !query 119 +-- !query 123 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 119 schema +-- !query 123 schema struct --- !query 119 output +-- !query 123 output 1 3 2 2 3 NULL 4 NULL --- !query 120 +-- !query 124 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 120 schema +-- !query 124 schema struct --- !query 120 output +-- !query 124 output 1 3 2 2 3 NULL 4 NULL --- !query 121 +-- !query 125 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 121 schema +-- !query 125 schema struct --- !query 121 output +-- !query 125 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 122 +-- !query 126 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 122 schema +-- !query 126 schema struct --- !query 122 output +-- !query 126 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 123 +-- !query 127 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 123 schema +-- !query 127 schema struct --- !query 123 output +-- !query 127 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 124 +-- !query 128 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 124 schema +-- !query 128 schema struct --- !query 124 output +-- !query 128 output 3 5 6.01 --- !query 125 +-- !query 129 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 125 schema +-- !query 129 schema struct --- !query 125 output +-- !query 129 output 1 2 2 1 3 0 4 0 --- !query 126 +-- !query 130 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 126 schema +-- !query 130 schema struct --- !query 126 output +-- !query 130 output 1 4 2 3 3 2 4 1 --- !query 127 +-- !query 131 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 127 schema +-- !query 131 schema struct --- !query 127 output +-- !query 131 output 0.0 11266.666666666666 13868.750000000002 @@ -2136,12 +2183,12 @@ struct --- !query 128 output +-- !query 132 output 0.0 11266.666666666666 13868.750000000002 @@ -2149,12 +2196,12 @@ struct --- !query 129 output +-- !query 133 output 0.0 11266.666666666666 13868.750000000002 @@ -2162,12 +2209,12 @@ struct --- !query 130 output +-- !query 134 output 0.0 11266.666666666666 13868.750000000002 @@ -2175,12 +2222,12 @@ struct --- !query 131 output +-- !query 135 output 16900.0 18491.666666666668 27129.999999999996 @@ -2188,12 +2235,12 @@ struct --- !query 132 output +-- !query 136 output 16900.0 18491.666666666668 27129.999999999996 @@ -2201,12 +2248,12 @@ struct --- !query 133 output +-- !query 137 output 16900.0 18491.666666666668 27129.999999999996 @@ -2214,12 +2261,12 @@ struct --- !query 134 output +-- !query 138 output 16900.0 18491.666666666668 27129.999999999996 @@ -2227,12 +2274,12 @@ struct --- !query 135 output +-- !query 139 output 16900.0 18491.666666666668 27129.999999999996 @@ -2240,12 +2287,12 @@ struct --- !query 136 output +-- !query 140 output 16900.0 18491.666666666668 27129.999999999996 @@ -2253,12 +2300,12 @@ struct --- !query 137 output +-- !query 141 output 16900.0 18491.666666666668 27129.999999999996 @@ -2266,12 +2313,12 @@ struct --- !query 138 output +-- !query 142 output 16900.0 18491.666666666668 27129.999999999996 @@ -2279,12 +2326,12 @@ struct --- !query 139 output +-- !query 143 output 0.0 106.14455552060438 117.76565713313879 @@ -2293,12 +2340,12 @@ struct --- !query 140 output +-- !query 144 output 0.0 106.14455552060438 117.76565713313879 @@ -2307,12 +2354,12 @@ struct --- !query 141 output +-- !query 145 output 0.0 106.14455552060438 117.76565713313879 @@ -2321,12 +2368,12 @@ struct --- !query 142 output +-- !query 146 output 0.0 106.14455552060438 117.76565713313879 @@ -2335,12 +2382,12 @@ struct --- !query 143 output +-- !query 147 output 130.0 135.9840676942217 164.7118696390761 @@ -2349,12 +2396,12 @@ struct --- !query 144 output +-- !query 148 output 130.0 135.9840676942217 164.7118696390761 @@ -2363,12 +2410,12 @@ struct --- !query 145 output +-- !query 149 output 130.0 135.9840676942217 164.7118696390761 @@ -2377,12 +2424,12 @@ struct --- !query 146 output +-- !query 150 output 130.0 135.9840676942217 164.7118696390761 @@ -2391,12 +2438,12 @@ struct --- !query 147 output +-- !query 151 output 130.0 135.9840676942217 164.7118696390761 @@ -2405,12 +2452,12 @@ struct --- !query 148 output +-- !query 152 output 130.0 135.9840676942217 164.7118696390761 @@ -2419,12 +2466,12 @@ struct --- !query 149 output +-- !query 153 output 130.0 135.9840676942217 164.7118696390761 @@ -2433,12 +2480,12 @@ struct --- !query 150 output +-- !query 154 output 130.0 135.9840676942217 164.7118696390761 @@ -2447,61 +2494,69 @@ struct --- !query 151 output +-- !query 155 output 1 1 2 2 3 NULL 4 NULL --- !query 152 +-- !query 156 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 152 schema +-- !query 156 schema struct --- !query 152 output +-- !query 156 output 1 3 2 2 3 NULL 4 NULL --- !query 153 +-- !query 157 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 153 schema +-- !query 157 schema struct --- !query 153 output +-- !query 157 output 1 3 2 6 3 9 4 7 --- !query 154 +-- !query 158 drop table numerics --- !query 154 schema +-- !query 158 schema struct<> --- !query 154 output +-- !query 158 output --- !query 155 +-- !query 159 drop table t1 --- !query 155 schema +-- !query 159 schema struct<> --- !query 155 output +-- !query 159 output --- !query 156 +-- !query 160 drop view int4_tbl --- !query 156 schema +-- !query 160 schema struct<> --- !query 156 output +-- !query 160 output + + + +-- !query 161 +drop table datetimes +-- !query 161 schema +struct<> +-- !query 161 output From d7b1f7760eb2212dc09ef104ec5b24cf7a6d1c29 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Tue, 30 Jul 2019 09:10:39 -0300 Subject: [PATCH 18/25] exchange jira numbers Signed-off-by: DylanGuedes --- sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql | 2 +- .../src/test/resources/sql-tests/results/pgSQL/window.sql.out | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 86f78b7f4dd72..9f4a35cd91860 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -122,7 +122,7 @@ SELECT sum(salary) OVER w1, count(*) OVER w2 FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary); -- subplan --- [SPARK-28553] subqueries must be aggregated before hand +-- [SPARK-28379] Correlated scalar subqueries must be aggregated -- SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) -- FROM tenk1 s WHERE unique2 < 10; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 01c2759b88589..f64d5a7c775cc 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1972,7 +1972,7 @@ struct +struct -- !query 114 output 1 From 9150d0d1ae8e0f033054978befd43e923dc56aa2 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Tue, 30 Jul 2019 15:15:23 -0300 Subject: [PATCH 19/25] remove query Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 4 +- .../sql-tests/results/pgSQL/window.sql.out | 222 +++++++++--------- 2 files changed, 109 insertions(+), 117 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 9f4a35cd91860..17717fb7516af 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -934,7 +934,8 @@ from t1 where f1 = f2; SELECT rank() OVER (ORDER BY length('abc')); -- can't order by another window function -SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); +-- [SPARK-28566] window functions should not be allowed in window definitions +-- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); -- some other errors select * from @@ -947,7 +948,6 @@ where rn < 10; -- [SPARK-28506] not handling usage of group function and window function at some conditions -- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; --- [SPARK-28086] Adds `random()` to Spark -- SELECT * FROM rank() OVER (ORDER BY random()); -- Output not being truncated diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index f64d5a7c775cc..4342f0b255308 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 162 +-- Number of queries: 161 -- !query 0 @@ -1970,20 +1970,12 @@ struct --- !query 114 output -1 - - --- !query 115 select * from (select row_number() over (order by salary) rn from empsalary) ss where rn < 10 --- !query 115 schema +-- !query 114 schema struct --- !query 115 output +-- !query 114 output 1 2 3 @@ -1995,181 +1987,194 @@ struct 9 --- !query 116 +-- !query 115 DROP TABLE empsalary --- !query 116 schema +-- !query 115 schema struct<> --- !query 116 output +-- !query 115 output --- !query 117 +-- !query 116 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 117 schema +-- !query 116 schema struct --- !query 117 output +-- !query 116 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 118 +-- !query 117 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 118 schema +-- !query 117 schema struct --- !query 118 output +-- !query 117 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 119 +-- !query 118 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 119 schema +-- !query 118 schema struct --- !query 119 output +-- !query 118 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 120 +-- !query 119 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 120 schema +-- !query 119 schema struct --- !query 120 output +-- !query 119 output 1 2 2 2.5 3 NULL 4 NULL --- !query 121 +-- !query 120 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 121 schema +-- !query 120 schema struct --- !query 121 output +-- !query 120 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 122 +-- !query 121 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 122 schema +-- !query 121 schema struct --- !query 122 output +-- !query 121 output 1 3 2 2 3 NULL 4 NULL --- !query 123 +-- !query 122 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 123 schema +-- !query 122 schema struct --- !query 123 output +-- !query 122 output 1 3 2 2 3 NULL 4 NULL --- !query 124 +-- !query 123 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 124 schema +-- !query 123 schema struct --- !query 124 output +-- !query 123 output 1 3 2 2 3 NULL 4 NULL --- !query 125 +-- !query 124 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 125 schema +-- !query 124 schema struct --- !query 125 output +-- !query 124 output 1 3.3000000000000003 2 2.2 3 NULL 4 NULL --- !query 126 +-- !query 125 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 126 schema +-- !query 125 schema struct --- !query 126 output +-- !query 125 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 127 +-- !query 126 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 127 schema +-- !query 126 schema struct --- !query 127 output +-- !query 126 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 128 +-- !query 127 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 128 schema +-- !query 127 schema struct --- !query 128 output +-- !query 127 output 3 5 6.01 --- !query 129 +-- !query 128 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 129 schema +-- !query 128 schema struct --- !query 129 output +-- !query 128 output 1 2 2 1 3 0 4 0 --- !query 130 +-- !query 129 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 130 schema +-- !query 129 schema struct --- !query 130 output +-- !query 129 output 1 4 2 3 3 2 4 1 +-- !query 130 +SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 130 schema +struct +-- !query 130 output +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 + + -- !query 131 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) @@ -2210,16 +2215,16 @@ struct +struct -- !query 134 output -0.0 -11266.666666666666 -13868.750000000002 -21703.999999999996 -4225.0 +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN -- !query 135 @@ -2262,7 +2267,7 @@ NaN -- !query 138 -SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 138 schema struct @@ -2314,16 +2319,17 @@ NaN -- !query 142 -SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) -- !query 142 schema -struct +struct -- !query 142 output -16900.0 -18491.666666666668 -27129.999999999996 -8450.0 -NaN +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 -- !query 143 @@ -2369,17 +2375,17 @@ struct +struct -- !query 146 output -0.0 -106.14455552060438 -117.76565713313879 -147.32277488562315 -147.32277488562315 -65.0 +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN -- !query 147 @@ -2425,8 +2431,8 @@ NaN -- !query 150 -SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 150 schema struct -- !query 150 output @@ -2481,57 +2487,51 @@ NaN -- !query 154 -SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 154 schema -struct --- !query 154 output -130.0 -135.9840676942217 -164.7118696390761 -164.7118696390761 -91.92388155425118 -NaN - - --- !query 155 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 155 schema +-- !query 154 schema struct --- !query 155 output +-- !query 154 output 1 1 2 2 3 NULL 4 NULL --- !query 156 +-- !query 155 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 156 schema +-- !query 155 schema struct --- !query 156 output +-- !query 155 output 1 3 2 2 3 NULL 4 NULL --- !query 157 +-- !query 156 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 157 schema +-- !query 156 schema struct --- !query 157 output +-- !query 156 output 1 3 2 6 3 9 4 7 --- !query 158 +-- !query 157 drop table numerics +-- !query 157 schema +struct<> +-- !query 157 output + + + +-- !query 158 +drop table t1 -- !query 158 schema struct<> -- !query 158 output @@ -2539,7 +2539,7 @@ struct<> -- !query 159 -drop table t1 +drop view int4_tbl -- !query 159 schema struct<> -- !query 159 output @@ -2547,16 +2547,8 @@ struct<> -- !query 160 -drop view int4_tbl +drop table datetimes -- !query 160 schema struct<> -- !query 160 output - - --- !query 161 -drop table datetimes --- !query 161 schema -struct<> --- !query 161 output - From 25181fd2729fbc5f76f61bac9b37364c090f75c7 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 31 Jul 2019 10:24:58 -0300 Subject: [PATCH 20/25] uncomment wrong queries Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 21 +- .../sql-tests/results/pgSQL/window.sql.out | 668 +++++++++--------- 2 files changed, 337 insertions(+), 352 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 17717fb7516af..1af6ba81526e7 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -313,14 +313,13 @@ SELECT * FROM v_window; -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude current row) as sum_rows FROM range(1, 10) i; -SELECT * FROM v_window; +-- SELECT * FROM v_window; -- [SPARK-28428] Spark `exclude` always expecting `()` -- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude group) as sum_rows FROM range(1, 10) i; - -SELECT * FROM v_window; +-- SELECT * FROM v_window; -- [SPARK-28428] Spark `exclude` always expecting `()` -- CREATE OR REPLACE TEMP VIEW v_window AS @@ -331,8 +330,7 @@ SELECT * FROM v_window; -- CREATE OR REPLACE TEMP VIEW v_window AS -- SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following -- exclude no others) as sum_rows FROM generate_series(1, 10) i; - -SELECT * FROM v_window; +-- SELECT * FROM v_window; CREATE OR REPLACE TEMP VIEW v_window AS SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i; @@ -938,9 +936,7 @@ SELECT rank() OVER (ORDER BY length('abc')); -- SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); -- some other errors -select * from -(select row_number() over (order by salary) rn from empsalary) ss -where rn < 10; +SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; -- [SPARK-28506] not handling usage of group function and window function at some conditions -- SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; @@ -948,7 +944,12 @@ where rn < 10; -- [SPARK-28506] not handling usage of group function and window function at some conditions -- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; --- SELECT * FROM rank() OVER (ORDER BY random()); +-- Since random() result may change due to seed issues, the behavior is actually unstable +SELECT * FROM rank() OVER (ORDER BY random()); + +SELECT * FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10; + +SELECT * FROM empsalary WHERE rank() OVER (ORDER BY random()); -- Output not being truncated -- SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); @@ -960,7 +961,7 @@ where rn < 10; -- SELECT count() OVER () FROM tenk1; -- [SPARK-28065] ntile only accepting positive (>0) values --- SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; +SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; -- [SPARK-27951] ANSI SQL: NTH_VALUE function -- SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1; diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 4342f0b255308..30901180aeed7 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 161 +-- Number of queries: 162 -- !query 0 @@ -930,19 +930,12 @@ struct -- !query 53 -SELECT * FROM v_window +CREATE OR REPLACE TEMP VIEW v_window AS +SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i -- !query 53 schema -struct +struct<> -- !query 53 output -1 3 -2 6 -3 9 -4 12 -5 15 -6 18 -7 21 -8 24 -9 17 + -- !query 54 @@ -962,61 +955,20 @@ struct -- !query 55 -SELECT * FROM v_window --- !query 55 schema -struct --- !query 55 output -1 3 -2 6 -3 9 -4 12 -5 15 -6 18 -7 21 -8 24 -9 17 - - --- !query 56 -CREATE OR REPLACE TEMP VIEW v_window AS -SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i --- !query 56 schema -struct<> --- !query 56 output - - - --- !query 57 -SELECT * FROM v_window --- !query 57 schema -struct --- !query 57 output -1 3 -2 6 -3 9 -4 12 -5 15 -6 18 -7 21 -8 24 -9 17 - - --- !query 58 DROP VIEW v_window --- !query 58 schema +-- !query 55 schema struct<> --- !query 58 output +-- !query 55 output --- !query 59 +-- !query 56 SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 59 schema +-- !query 56 schema struct --- !query 59 output +-- !query 56 output 12 1 1 12 5 1 12 9 1 @@ -1029,13 +981,13 @@ NULL 4 0 NULL 8 0 --- !query 60 +-- !query 57 SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 60 schema +-- !query 57 schema struct --- !query 60 output +-- !query 57 output 10 2 2 10 6 2 18 1 1 @@ -1048,13 +1000,13 @@ NULL 3 3 NULL 7 3 --- !query 61 +-- !query 58 SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 61 schema +-- !query 58 schema struct --- !query 61 output +-- !query 58 output 10 3 3 10 7 3 12 4 0 @@ -1067,7 +1019,7 @@ struct --- !query 62 output +-- !query 59 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1088,7 +1040,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 63 +-- !query 60 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1098,9 +1050,9 @@ from union all select null, 43) ss window w as (order by ss.id asc nulls last range between 2 preceding and 2 following) --- !query 63 schema +-- !query 60 schema struct --- !query 63 output +-- !query 60 output 1 1 1 3 2 2 1 4 3 3 1 4 @@ -1109,7 +1061,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 64 +-- !query 61 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1119,9 +1071,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls first range between 2 preceding and 2 following) --- !query 64 schema +-- !query 61 schema struct --- !query 64 output +-- !query 61 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1130,7 +1082,7 @@ NULL 42 42 43 NULL 43 42 43 --- !query 65 +-- !query 62 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w @@ -1140,9 +1092,9 @@ from union all select null, 43) ss window w as (order by ss.id desc nulls last range between 2 preceding and 2 following) --- !query 65 schema +-- !query 62 schema struct --- !query 65 output +-- !query 62 output 1 1 3 1 2 2 4 1 3 3 4 1 @@ -1151,80 +1103,80 @@ NULL 42 42 43 NULL 43 42 43 --- !query 66 +-- !query 63 select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) from range(32764, 32766) x --- !query 66 schema +-- !query 63 schema struct --- !query 66 output +-- !query 63 output 32764 32765 32765 32765 --- !query 67 +-- !query 64 select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) from range(-32766, -32764) x --- !query 67 schema +-- !query 64 schema struct --- !query 67 output +-- !query 64 output -32765 -32766 -32766 -32766 --- !query 68 +-- !query 65 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(2147483644, 2147483646) x --- !query 68 schema +-- !query 65 schema struct --- !query 68 output +-- !query 65 output 2147483644 2147483645 2147483645 2147483645 --- !query 69 +-- !query 66 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-2147483646, -2147483644) x --- !query 69 schema +-- !query 66 schema struct --- !query 69 output +-- !query 66 output -2147483645 -2147483646 -2147483646 -2147483646 --- !query 70 +-- !query 67 select x.id, last(x.id) over (order by x.id range between current row and 4 following) from range(9223372036854775804, 9223372036854775806) x --- !query 70 schema +-- !query 67 schema struct --- !query 70 output +-- !query 67 output 9223372036854775804 NULL 9223372036854775805 NULL --- !query 71 +-- !query 68 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) from range(-9223372036854775806, -9223372036854775804) x --- !query 71 schema +-- !query 68 schema struct --- !query 71 output +-- !query 68 output -9223372036854775805 NULL -9223372036854775806 NULL --- !query 72 +-- !query 69 create table numerics ( id int, f_float4 float, f_float8 float, f_numeric int ) using parquet --- !query 72 schema +-- !query 69 schema struct<> --- !query 72 output +-- !query 69 output --- !query 73 +-- !query 70 insert into numerics values (1, -3, -3, -3), (2, -1, -1, -1), @@ -1233,20 +1185,20 @@ insert into numerics values (5, 1.12, 1.12, 1.12), (6, 2, 2, 2), (7, 100, 100, 100) --- !query 73 schema +-- !query 70 schema struct<> --- !query 73 output +-- !query 70 output --- !query 74 +-- !query 71 select id, f_float4, first(id) over w, last(id) over w from numerics window w as (order by f_float4 range between 1 preceding and 1 following) --- !query 74 schema +-- !query 71 schema struct --- !query 74 output +-- !query 71 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 3 @@ -1256,14 +1208,14 @@ struct --- !query 75 output +-- !query 72 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 4 @@ -1273,14 +1225,14 @@ struct --- !query 76 output +-- !query 73 output 1 -3.0 NULL NULL 2 -1.0 NULL NULL 3 0.0 NULL NULL @@ -1290,14 +1242,14 @@ struct --- !query 77 output +-- !query 74 output 1 -3.0 1 7 2 -1.0 2 7 3 0.0 2 7 @@ -1307,16 +1259,16 @@ struct --- !query 78 output +-- !query 75 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 3 @@ -1326,14 +1278,14 @@ struct --- !query 79 output +-- !query 76 output 1 -3.0 1 1 2 -1.0 2 3 3 0.0 2 4 @@ -1343,14 +1295,14 @@ struct --- !query 80 output +-- !query 77 output 1 -3.0 NULL NULL 2 -1.0 NULL NULL 3 0.0 NULL NULL @@ -1360,14 +1312,14 @@ struct --- !query 81 output +-- !query 78 output 1 -3.0 1 7 2 -1.0 2 7 3 0.0 2 7 @@ -1377,16 +1329,16 @@ struct --- !query 82 output +-- !query 79 output 1 -3 1 1 2 -1 2 3 3 0 2 5 @@ -1396,14 +1348,14 @@ struct --- !query 83 output +-- !query 80 output 1 -3 1 1 2 -1 2 3 3 0 2 5 @@ -1413,14 +1365,14 @@ struct --- !query 84 output +-- !query 81 output 1 -3 1 1 2 -1 2 3 3 0 2 5 @@ -1430,16 +1382,16 @@ struct --- !query 85 output +-- !query 82 output 1 -3 NULL NULL 2 -1 NULL NULL 3 0 NULL NULL @@ -1449,7 +1401,7 @@ struct --- !query 86 output +-- !query 83 output --- !query 87 +-- !query 84 insert into datetimes values (1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), (2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), @@ -1479,19 +1431,19 @@ insert into datetimes values (8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), (9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), (10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54') --- !query 87 schema +-- !query 84 schema struct<> --- !query 87 output +-- !query 84 output --- !query 88 +-- !query 85 SELECT sum(unique1) over (order by four range between unbounded preceding and current row), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 88 schema +-- !query 85 schema struct --- !query 88 output +-- !query 85 output 12 0 0 12 4 0 12 8 0 @@ -1504,13 +1456,13 @@ struct --- !query 89 output +-- !query 86 output 45 0 0 45 1 1 45 2 2 @@ -1523,13 +1475,13 @@ struct --- !query 90 output +-- !query 87 output 10 3 3 10 7 3 18 2 2 @@ -1542,13 +1494,13 @@ struct --- !query 91 output +-- !query 88 output 18 3 3 18 7 3 33 2 2 @@ -1561,13 +1513,13 @@ struct --- !query 92 output +-- !query 89 output 10 2 2 10 6 2 18 1 1 @@ -1580,13 +1532,13 @@ NULL 3 3 NULL 7 3 --- !query 93 +-- !query 90 SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 93 schema +-- !query 90 schema struct --- !query 93 output +-- !query 90 output 35 0 0 35 4 0 35 8 0 @@ -1599,13 +1551,13 @@ struct --- !query 94 output +-- !query 91 output 12 1 1 12 5 1 12 9 1 @@ -1618,13 +1570,13 @@ NULL 4 0 NULL 8 0 --- !query 95 +-- !query 92 SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 95 schema +-- !query 92 schema struct --- !query 95 output +-- !query 92 output 10 3 3 10 7 3 12 0 0 @@ -1637,13 +1589,13 @@ struct --- !query 96 output +-- !query 93 output 0 0 0 0 1 1 1 1 2 2 2 2 @@ -1656,16 +1608,16 @@ struct --- !query 97 output +-- !query 94 output 1 4 11 33 13 39 @@ -1685,16 +1637,16 @@ struct --- !query 98 output +-- !query 95 output 1 1 11 11 13 13 @@ -1714,16 +1666,16 @@ struct --- !query 99 output +-- !query 96 output 1 1 11 11 13 13 @@ -1743,7 +1695,7 @@ struct --- !query 100 output +-- !query 97 output 1 2 1 3 1 7 @@ -1781,7 +1733,7 @@ struct --- !query 101 output +-- !query 98 output 1 3 1 3 1 3 @@ -1819,7 +1771,7 @@ struct --- !query 102 output +-- !query 99 output 1 3 1 3 1 3 @@ -1857,154 +1809,174 @@ struct --- !query 103 output +-- !query 100 output --- !query 104 +-- !query 101 create table t1 (f1 int, f2 int) using parquet --- !query 104 schema +-- !query 101 schema struct<> --- !query 104 output +-- !query 101 output --- !query 105 +-- !query 102 insert into t1 values (1,1),(1,2),(2,2) --- !query 105 schema +-- !query 102 schema struct<> --- !query 105 output +-- !query 102 output --- !query 106 +-- !query 103 select f1, sum(f1) over (partition by f1 order by f1 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 106 schema +-- !query 103 schema struct --- !query 106 output +-- !query 103 output 1 1 2 2 --- !query 107 +-- !query 104 -- error, must have order by select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 107 schema +-- !query 104 schema struct --- !query 107 output +-- !query 104 output +1 NULL +2 NULL + + +-- !query 105 +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) +from t1 where f1 = f2 +-- !query 105 schema +struct +-- !query 105 output 1 NULL 2 NULL +-- !query 106 +select f1, sum(f1) over (partition by f1, +f1 order by f2 range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 106 schema +struct +-- !query 106 output +1 1 +2 2 + + +-- !query 107 +select f1, sum(f1) over (partition by f1 order by f2 +range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- !query 107 schema +struct +-- !query 107 output +1 1 +2 2 + + -- !query 108 -select f1, sum(f1) over (partition by f1, f2 order by f2 -range between 1 following and 2 following) +select f1, sum(f1) over (partition by f1, f1 order by f2 +range between 2 preceding and 1 preceding) from t1 where f1 = f2 -- !query 108 schema -struct +struct -- !query 108 output 1 NULL 2 NULL -- !query 109 -select f1, sum(f1) over (partition by f1, -f1 order by f2 range between 1 preceding and 1 following) +select f1, sum(f1) over (partition by f1, f2 order by f2 +range between 1 following and 2 following) from t1 where f1 = f2 -- !query 109 schema -struct +struct -- !query 109 output -1 1 -2 2 +1 NULL +2 NULL -- !query 110 -select f1, sum(f1) over (partition by f1 order by f2 -range between 1 preceding and 1 following) -from t1 where f1 = f2 +SELECT rank() OVER (ORDER BY length('abc')) -- !query 110 schema -struct +struct -- !query 110 output -1 1 -2 2 +1 -- !query 111 -select f1, sum(f1) over (partition by f1, f1 order by f2 -range between 2 preceding and 1 preceding) -from t1 where f1 = f2 +SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10 -- !query 111 schema -struct +struct<> -- !query 111 output -1 NULL -2 NULL +org.apache.spark.sql.AnalysisException +It is not allowed to use window functions inside WHERE and HAVING clauses; -- !query 112 -select f1, sum(f1) over (partition by f1, f2 order by f2 -range between 1 following and 2 following) -from t1 where f1 = f2 +SELECT * FROM rank() OVER (ORDER BY random()) -- !query 112 schema -struct +struct<> -- !query 112 output -1 NULL -2 NULL +org.apache.spark.sql.catalyst.parser.ParseException + +no viable alternative at input 'ORDER'(line 1, pos 27) + +== SQL == +SELECT * FROM rank() OVER (ORDER BY random()) +---------------------------^^^ -- !query 113 -SELECT rank() OVER (ORDER BY length('abc')) +SELECT * FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10 -- !query 113 schema -struct +struct<> -- !query 113 output -1 +org.apache.spark.sql.AnalysisException +It is not allowed to use window functions inside WHERE and HAVING clauses; -- !query 114 -select * from -(select row_number() over (order by salary) rn from empsalary) ss -where rn < 10 +SELECT * FROM empsalary WHERE rank() OVER (ORDER BY random()) -- !query 114 schema -struct +struct<> -- !query 114 output -1 -2 -3 -4 -5 -6 -7 -8 -9 +org.apache.spark.sql.AnalysisException +It is not allowed to use window functions inside WHERE and HAVING clauses; -- !query 115 -DROP TABLE empsalary +SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 -- !query 115 schema struct<> -- !query 115 output - +org.apache.spark.sql.AnalysisException +cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; line 1 pos 7 -- !query 116 -SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +DROP TABLE empsalary -- !query 116 schema -struct +struct<> -- !query 116 output -1 1.5 -2 2.0 -3 NULL -4 NULL + -- !query 117 @@ -2033,36 +2005,36 @@ struct +struct -- !query 119 output -1 2 -2 2.5 +1 1.5 +2 2.0 3 NULL 4 NULL -- !query 120 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) -- !query 120 schema -struct +struct -- !query 120 output -1 NULL -2 NULL +1 2 +2 2.5 3 NULL 4 NULL -- !query 121 -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) -- !query 121 schema -struct +struct -- !query 121 output -1 3 -2 2 +1 NULL +2 NULL 3 NULL 4 NULL @@ -2093,88 +2065,87 @@ struct +struct -- !query 124 output -1 3.3000000000000003 -2 2.2 +1 3 +2 2 3 NULL 4 NULL -- !query 125 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) -- !query 125 schema struct -- !query 125 output +1 3.3000000000000003 +2 2.2 +3 NULL +4 NULL + + +-- !query 126 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- !query 126 schema +struct +-- !query 126 output 1 NULL 2 NULL 3 NULL 4 NULL --- !query 126 +-- !query 127 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 126 schema +-- !query 127 schema struct --- !query 126 output +-- !query 127 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 127 +-- !query 128 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 127 schema +-- !query 128 schema struct --- !query 127 output +-- !query 128 output 3 5 6.01 --- !query 128 +-- !query 129 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 128 schema +-- !query 129 schema struct --- !query 128 output +-- !query 129 output 1 2 2 1 3 0 4 0 --- !query 129 +-- !query 130 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 129 schema +-- !query 130 schema struct --- !query 129 output +-- !query 130 output 1 4 2 3 3 2 4 1 --- !query 130 -SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 130 schema -struct --- !query 130 output -0.0 -11266.666666666666 -13868.750000000002 -21703.999999999996 -4225.0 - - -- !query 131 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) @@ -2215,16 +2186,16 @@ struct +struct -- !query 134 output -16900.0 -18491.666666666668 -27129.999999999996 -8450.0 -NaN +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 -- !query 135 @@ -2267,7 +2238,7 @@ NaN -- !query 138 -SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 138 schema struct @@ -2319,17 +2290,16 @@ NaN -- !query 142 -SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 142 schema -struct +struct -- !query 142 output -0.0 -106.14455552060438 -117.76565713313879 -147.32277488562315 -147.32277488562315 -65.0 +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN -- !query 143 @@ -2375,17 +2345,17 @@ struct +struct -- !query 146 output -130.0 -135.9840676942217 -164.7118696390761 -164.7118696390761 -91.92388155425118 -NaN +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 -- !query 147 @@ -2431,8 +2401,8 @@ NaN -- !query 150 -SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) -- !query 150 schema struct -- !query 150 output @@ -2487,51 +2457,57 @@ NaN -- !query 154 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 154 schema +struct +-- !query 154 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 155 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 154 schema +-- !query 155 schema struct --- !query 154 output +-- !query 155 output 1 1 2 2 3 NULL 4 NULL --- !query 155 +-- !query 156 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 155 schema +-- !query 156 schema struct --- !query 155 output +-- !query 156 output 1 3 2 2 3 NULL 4 NULL --- !query 156 +-- !query 157 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 156 schema +-- !query 157 schema struct --- !query 156 output +-- !query 157 output 1 3 2 6 3 9 4 7 --- !query 157 -drop table numerics --- !query 157 schema -struct<> --- !query 157 output - - - -- !query 158 -drop table t1 +drop table numerics -- !query 158 schema struct<> -- !query 158 output @@ -2539,7 +2515,7 @@ struct<> -- !query 159 -drop view int4_tbl +drop table t1 -- !query 159 schema struct<> -- !query 159 output @@ -2547,8 +2523,16 @@ struct<> -- !query 160 -drop table datetimes +drop view int4_tbl -- !query 160 schema struct<> -- !query 160 output + + +-- !query 161 +drop table datetimes +-- !query 161 schema +struct<> +-- !query 161 output + From e776cc36426a08bfb91d7bc062db7917ba7968e9 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 1 Aug 2019 11:13:16 -0300 Subject: [PATCH 21/25] update with casting types Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 21 +- .../sql-tests/results/pgSQL/window.sql.out | 332 +++++++++--------- 2 files changed, 181 insertions(+), 172 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 1af6ba81526e7..9ab873de67180 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -951,14 +951,14 @@ SELECT * FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10; SELECT * FROM empsalary WHERE rank() OVER (ORDER BY random()); --- Output not being truncated --- SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); +-- The original query currently outputs too many rows, so just count the output number +SELECT count(*) FROM (select count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1)); --- Output not being truncated --- SELECT rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1; +-- The original query currently outputs too many rows, so just count the output number +SELECT count(*) FROM (select rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1); --- Output not being truncated --- SELECT count() OVER () FROM tenk1; +-- The original query currently outputs too many rows, so just count the output number +SELECT count(*) FROM (select count() OVER () FROM tenk1); -- [SPARK-28065] ntile only accepting positive (>0) values SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; @@ -1034,7 +1034,7 @@ SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWIN SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v); -SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT i,AVG(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) @@ -1046,10 +1046,11 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWIN SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v); +-- The cast syntax is present in PgSQL for legacy reasons and Spark will not recognize a money field +-- SELECT i,SUM(v::money) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +-- FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v); -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT i,SUM(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 30901180aeed7..f37657e485415 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 162 +-- Number of queries: 164 -- !query 0 @@ -1963,195 +1963,203 @@ It is not allowed to use window functions inside WHERE and HAVING clauses; -- !query 115 -SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 +SELECT count(*) FROM (select count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1)) -- !query 115 schema -struct<> +struct -- !query 115 output +10000 + + +-- !query 116 +SELECT count(*) FROM (select rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1) +-- !query 116 schema +struct +-- !query 116 output +10000 + + +-- !query 117 +SELECT count(*) FROM (select count() OVER () FROM tenk1) +-- !query 117 schema +struct +-- !query 117 output +10000 + + +-- !query 118 +SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 +-- !query 118 schema +struct<> +-- !query 118 output org.apache.spark.sql.AnalysisException cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; line 1 pos 7 --- !query 116 +-- !query 119 DROP TABLE empsalary --- !query 116 schema +-- !query 119 schema struct<> --- !query 116 output +-- !query 119 output --- !query 117 +-- !query 120 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 117 schema +-- !query 120 schema struct --- !query 117 output +-- !query 120 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 118 +-- !query 121 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 118 schema +-- !query 121 schema struct --- !query 118 output +-- !query 121 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 119 +-- !query 122 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 119 schema +-- !query 122 schema struct --- !query 119 output +-- !query 122 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 120 +-- !query 123 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 120 schema +-- !query 123 schema struct --- !query 120 output +-- !query 123 output 1 2 2 2.5 3 NULL 4 NULL --- !query 121 -SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +-- !query 124 +SELECT i,AVG(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 121 schema -struct --- !query 121 output -1 NULL -2 NULL -3 NULL -4 NULL +-- !query 124 schema +struct<> +-- !query 124 output +org.apache.spark.sql.AnalysisException +cannot resolve 'avg(CAST(`v` AS INTERVAL))' due to data type mismatch: function average requires numeric types, not interval; line 1 pos 9 --- !query 122 +-- !query 125 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 122 schema +-- !query 125 schema struct --- !query 122 output +-- !query 125 output 1 3 2 2 3 NULL 4 NULL --- !query 123 +-- !query 126 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 123 schema +-- !query 126 schema struct --- !query 123 output +-- !query 126 output 1 3 2 2 3 NULL 4 NULL --- !query 124 +-- !query 127 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 124 schema +-- !query 127 schema struct --- !query 124 output +-- !query 127 output 1 3 2 2 3 NULL 4 NULL --- !query 125 -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) --- !query 125 schema -struct --- !query 125 output -1 3.3000000000000003 -2 2.2 -3 NULL -4 NULL - - --- !query 126 -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +-- !query 128 +SELECT i,SUM(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 126 schema -struct --- !query 126 output -1 NULL -2 NULL -3 NULL -4 NULL +-- !query 128 schema +struct<> +-- !query 128 output +org.apache.spark.sql.AnalysisException +cannot resolve 'sum(CAST(`v` AS INTERVAL))' due to data type mismatch: function sum requires numeric types, not interval; line 1 pos 9 --- !query 127 +-- !query 129 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 127 schema +-- !query 129 schema struct --- !query 127 output +-- !query 129 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 128 +-- !query 130 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 128 schema +-- !query 130 schema struct --- !query 128 output +-- !query 130 output 3 5 6.01 --- !query 129 +-- !query 131 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 129 schema +-- !query 131 schema struct --- !query 129 output +-- !query 131 output 1 2 2 1 3 0 4 0 --- !query 130 +-- !query 132 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 130 schema +-- !query 132 schema struct --- !query 130 output +-- !query 132 output 1 4 2 3 3 2 4 1 --- !query 131 +-- !query 133 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 131 schema +-- !query 133 schema struct --- !query 131 output +-- !query 133 output 0.0 11266.666666666666 13868.750000000002 @@ -2159,12 +2167,12 @@ struct --- !query 132 output +-- !query 134 output 0.0 11266.666666666666 13868.750000000002 @@ -2172,12 +2180,12 @@ struct --- !query 133 output +-- !query 135 output 0.0 11266.666666666666 13868.750000000002 @@ -2185,12 +2193,12 @@ struct --- !query 134 output +-- !query 136 output 0.0 11266.666666666666 13868.750000000002 @@ -2198,12 +2206,12 @@ struct --- !query 135 output +-- !query 137 output 16900.0 18491.666666666668 27129.999999999996 @@ -2211,12 +2219,12 @@ struct --- !query 136 output +-- !query 138 output 16900.0 18491.666666666668 27129.999999999996 @@ -2224,12 +2232,12 @@ struct --- !query 137 output +-- !query 139 output 16900.0 18491.666666666668 27129.999999999996 @@ -2237,12 +2245,12 @@ struct --- !query 138 output +-- !query 140 output 16900.0 18491.666666666668 27129.999999999996 @@ -2250,12 +2258,12 @@ struct --- !query 139 output +-- !query 141 output 16900.0 18491.666666666668 27129.999999999996 @@ -2263,12 +2271,12 @@ struct --- !query 140 output +-- !query 142 output 16900.0 18491.666666666668 27129.999999999996 @@ -2276,12 +2284,12 @@ struct --- !query 141 output +-- !query 143 output 16900.0 18491.666666666668 27129.999999999996 @@ -2289,12 +2297,12 @@ struct --- !query 142 output +-- !query 144 output 16900.0 18491.666666666668 27129.999999999996 @@ -2302,12 +2310,12 @@ struct --- !query 143 output +-- !query 145 output 0.0 106.14455552060438 117.76565713313879 @@ -2316,12 +2324,12 @@ struct --- !query 144 output +-- !query 146 output 0.0 106.14455552060438 117.76565713313879 @@ -2330,12 +2338,12 @@ struct --- !query 145 output +-- !query 147 output 0.0 106.14455552060438 117.76565713313879 @@ -2344,12 +2352,12 @@ struct --- !query 146 output +-- !query 148 output 0.0 106.14455552060438 117.76565713313879 @@ -2358,12 +2366,12 @@ struct --- !query 147 output +-- !query 149 output 130.0 135.9840676942217 164.7118696390761 @@ -2372,12 +2380,12 @@ struct --- !query 148 output +-- !query 150 output 130.0 135.9840676942217 164.7118696390761 @@ -2386,12 +2394,12 @@ struct --- !query 149 output +-- !query 151 output 130.0 135.9840676942217 164.7118696390761 @@ -2400,12 +2408,12 @@ struct --- !query 150 output +-- !query 152 output 130.0 135.9840676942217 164.7118696390761 @@ -2414,12 +2422,12 @@ struct --- !query 151 output +-- !query 153 output 130.0 135.9840676942217 164.7118696390761 @@ -2428,12 +2436,12 @@ struct --- !query 152 output +-- !query 154 output 130.0 135.9840676942217 164.7118696390761 @@ -2442,12 +2450,12 @@ struct --- !query 153 output +-- !query 155 output 130.0 135.9840676942217 164.7118696390761 @@ -2456,12 +2464,12 @@ struct --- !query 154 output +-- !query 156 output 130.0 135.9840676942217 164.7118696390761 @@ -2470,69 +2478,69 @@ struct --- !query 155 output +-- !query 157 output 1 1 2 2 3 NULL 4 NULL --- !query 156 +-- !query 158 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 156 schema +-- !query 158 schema struct --- !query 156 output +-- !query 158 output 1 3 2 2 3 NULL 4 NULL --- !query 157 +-- !query 159 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 157 schema +-- !query 159 schema struct --- !query 157 output +-- !query 159 output 1 3 2 6 3 9 4 7 --- !query 158 +-- !query 160 drop table numerics --- !query 158 schema +-- !query 160 schema struct<> --- !query 158 output +-- !query 160 output --- !query 159 +-- !query 161 drop table t1 --- !query 159 schema +-- !query 161 schema struct<> --- !query 159 output +-- !query 161 output --- !query 160 +-- !query 162 drop view int4_tbl --- !query 160 schema +-- !query 162 schema struct<> --- !query 160 output +-- !query 162 output --- !query 161 +-- !query 163 drop table datetimes --- !query 161 schema +-- !query 163 schema struct<> --- !query 161 output +-- !query 163 output From ef230204087dc5f860d22b5635610764e8cd5f03 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 2 Aug 2019 09:07:57 -0300 Subject: [PATCH 22/25] adds new jira Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 12 +- .../sql-tests/results/pgSQL/window.sql.out | 244 ++++++++---------- 2 files changed, 120 insertions(+), 136 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 9ab873de67180..25529cca54216 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -1034,8 +1034,9 @@ SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWIN SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v); -SELECT i,AVG(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); +-- [SPARK-28602] Spark does not recognize 'interval' type as 'numeric' +-- SELECT i,AVG(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +-- FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); @@ -1050,8 +1051,9 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWIN -- SELECT i,SUM(v::money) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) -- FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v); -SELECT i,SUM(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); +-- [SPARK-28602] Spark does not recognize 'interval' type as 'numeric' +-- SELECT i,SUM(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +-- FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v); @@ -1113,6 +1115,8 @@ SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOL SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); +-- For the following queries Spark result differs from PgSQL: +-- Spark handles division by zero as 'NaN' instead of 'NULL', which is the PgSQL behaviour SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n); diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index f37657e485415..2c6a780eb8415 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 164 +-- Number of queries: 162 -- !query 0 @@ -2052,13 +2052,15 @@ struct +struct -- !query 124 output -org.apache.spark.sql.AnalysisException -cannot resolve 'avg(CAST(`v` AS INTERVAL))' due to data type mismatch: function average requires numeric types, not interval; line 1 pos 9 +1 3 +2 2 +3 NULL +4 NULL -- !query 125 @@ -2086,80 +2088,58 @@ struct --- !query 127 output -1 3 -2 2 -3 NULL -4 NULL - - --- !query 128 -SELECT i,SUM(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) --- !query 128 schema -struct<> --- !query 128 output -org.apache.spark.sql.AnalysisException -cannot resolve 'sum(CAST(`v` AS INTERVAL))' due to data type mismatch: function sum requires numeric types, not interval; line 1 pos 9 - - --- !query 129 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 129 schema +-- !query 127 schema struct --- !query 129 output +-- !query 127 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 130 +-- !query 128 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 130 schema +-- !query 128 schema struct --- !query 130 output +-- !query 128 output 3 5 6.01 --- !query 131 +-- !query 129 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 131 schema +-- !query 129 schema struct --- !query 131 output +-- !query 129 output 1 2 2 1 3 0 4 0 --- !query 132 +-- !query 130 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 132 schema +-- !query 130 schema struct --- !query 132 output +-- !query 130 output 1 4 2 3 3 2 4 1 --- !query 133 +-- !query 131 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 133 schema +-- !query 131 schema struct --- !query 133 output +-- !query 131 output 0.0 11266.666666666666 13868.750000000002 @@ -2167,12 +2147,12 @@ struct --- !query 134 output +-- !query 132 output 0.0 11266.666666666666 13868.750000000002 @@ -2180,12 +2160,12 @@ struct --- !query 135 output +-- !query 133 output 0.0 11266.666666666666 13868.750000000002 @@ -2193,12 +2173,12 @@ struct --- !query 136 output +-- !query 134 output 0.0 11266.666666666666 13868.750000000002 @@ -2206,12 +2186,12 @@ struct --- !query 137 output +-- !query 135 output 16900.0 18491.666666666668 27129.999999999996 @@ -2219,12 +2199,12 @@ struct --- !query 138 output +-- !query 136 output 16900.0 18491.666666666668 27129.999999999996 @@ -2232,12 +2212,12 @@ struct --- !query 139 output +-- !query 137 output 16900.0 18491.666666666668 27129.999999999996 @@ -2245,12 +2225,12 @@ struct --- !query 140 output +-- !query 138 output 16900.0 18491.666666666668 27129.999999999996 @@ -2258,12 +2238,12 @@ struct --- !query 141 output +-- !query 139 output 16900.0 18491.666666666668 27129.999999999996 @@ -2271,12 +2251,12 @@ struct --- !query 142 output +-- !query 140 output 16900.0 18491.666666666668 27129.999999999996 @@ -2284,12 +2264,12 @@ struct --- !query 143 output +-- !query 141 output 16900.0 18491.666666666668 27129.999999999996 @@ -2297,12 +2277,12 @@ struct --- !query 144 output +-- !query 142 output 16900.0 18491.666666666668 27129.999999999996 @@ -2310,12 +2290,12 @@ struct --- !query 145 output +-- !query 143 output 0.0 106.14455552060438 117.76565713313879 @@ -2324,12 +2304,12 @@ struct --- !query 146 output +-- !query 144 output 0.0 106.14455552060438 117.76565713313879 @@ -2338,12 +2318,12 @@ struct --- !query 147 output +-- !query 145 output 0.0 106.14455552060438 117.76565713313879 @@ -2352,12 +2332,12 @@ struct --- !query 148 output +-- !query 146 output 0.0 106.14455552060438 117.76565713313879 @@ -2366,12 +2346,12 @@ struct --- !query 149 output +-- !query 147 output 130.0 135.9840676942217 164.7118696390761 @@ -2380,12 +2360,12 @@ struct --- !query 150 output +-- !query 148 output 130.0 135.9840676942217 164.7118696390761 @@ -2394,12 +2374,12 @@ struct --- !query 151 output +-- !query 149 output 130.0 135.9840676942217 164.7118696390761 @@ -2408,12 +2388,12 @@ struct --- !query 152 output +-- !query 150 output 130.0 135.9840676942217 164.7118696390761 @@ -2422,12 +2402,12 @@ struct --- !query 153 output +-- !query 151 output 130.0 135.9840676942217 164.7118696390761 @@ -2436,12 +2416,12 @@ struct --- !query 154 output +-- !query 152 output 130.0 135.9840676942217 164.7118696390761 @@ -2450,12 +2430,12 @@ struct --- !query 155 output +-- !query 153 output 130.0 135.9840676942217 164.7118696390761 @@ -2464,12 +2444,12 @@ struct --- !query 156 output +-- !query 154 output 130.0 135.9840676942217 164.7118696390761 @@ -2478,69 +2458,69 @@ struct --- !query 157 output +-- !query 155 output 1 1 2 2 3 NULL 4 NULL --- !query 158 +-- !query 156 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 158 schema +-- !query 156 schema struct --- !query 158 output +-- !query 156 output 1 3 2 2 3 NULL 4 NULL --- !query 159 +-- !query 157 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 159 schema +-- !query 157 schema struct --- !query 159 output +-- !query 157 output 1 3 2 6 3 9 4 7 --- !query 160 +-- !query 158 drop table numerics --- !query 160 schema +-- !query 158 schema struct<> --- !query 160 output +-- !query 158 output --- !query 161 +-- !query 159 drop table t1 --- !query 161 schema +-- !query 159 schema struct<> --- !query 161 output +-- !query 159 output --- !query 162 +-- !query 160 drop view int4_tbl --- !query 162 schema +-- !query 160 schema struct<> --- !query 162 output +-- !query 160 output --- !query 163 +-- !query 161 drop table datetimes --- !query 163 schema +-- !query 161 schema struct<> --- !query 163 output +-- !query 161 output From 60c626a2926edb45f2b0028b2b4834826ad0aef0 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 7 Aug 2019 17:27:25 -0300 Subject: [PATCH 23/25] adds groups jira Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 432 ++++++--- .../sql-tests/results/pgSQL/window.sql.out | 854 +++++++----------- 2 files changed, 633 insertions(+), 653 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 25529cca54216..7360cb96a0f62 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -67,6 +67,8 @@ SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHER -- [SPARK-28068] `lag` second argument must be a literal in Spark -- SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; + +-- [SPARK-28068] `lag` second argument must be a literal in Spark -- SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10; @@ -269,9 +271,9 @@ unique1, four FROM tenk1 WHERE unique1 < 10; -- [SPARK-28428] Spark `exclude` always expecting `()` --- SELECT sum(unique1) over (w range between current row and unbounded following), --- unique1, four --- FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); +SELECT sum(unique1) over (w range between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four); -- [SPARK-28428] Spark `exclude` always expecting `()` -- SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), @@ -304,7 +306,7 @@ FROM tenk1 WHERE unique1 < 10; CREATE TEMP VIEW v_window AS SELECT i.id, sum(i.id) over (order by i.id rows between 1 preceding and 1 following) as sum_rows -FROM range(1, 10) i; +FROM range(1, 11) i; SELECT * FROM v_window; @@ -332,10 +334,10 @@ SELECT * FROM v_window; -- exclude no others) as sum_rows FROM generate_series(1, 10) i; -- SELECT * FROM v_window; -CREATE OR REPLACE TEMP VIEW v_window AS -SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i; - -SELECT * FROM v_window; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- CREATE OR REPLACE TEMP VIEW v_window AS +-- SELECT i.id, sum(i.id) over (order by i.id groups between 1 preceding and 1 following) as sum_rows FROM range(1, 11) i; +-- SELECT * FROM v_window; DROP VIEW v_window; @@ -423,10 +425,9 @@ FROM tenk1 WHERE unique1 < 10; -- nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following), -- salary from empsalary; --- [SPARK-27951] ANSI SQL: NTH_VALUE function --- select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), --- lag(salary) over(order by salary range between 1000 preceding and 1000 following), --- salary from empsalary; +select last(salary) over(order by salary range between 1000 preceding and 1000 following), +lag(salary) over(order by salary range between 1000 preceding and 1000 following), +salary from empsalary; -- [SPARK-27951] ANSI SQL: NTH_VALUE function -- select first_value(salary) over(order by salary range between 1000 following and 3000 following @@ -474,7 +475,7 @@ select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w from - (select x.id, x.id as y from range(1,5) as x + (select x.id, x.id as y from range(1,6) as x union all select null, 42 union all select null, 43) ss window w as @@ -484,7 +485,7 @@ select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w from - (select x.id, x.id as y from range(1,5) as x + (select x.id, x.id as y from range(1,6) as x union all select null, 42 union all select null, 43) ss window w as @@ -494,7 +495,7 @@ select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w from - (select x.id, x.id as y from range(1,5) as x + (select x.id, x.id as y from range(1,6) as x union all select null, 42 union all select null, 43) ss window w as @@ -504,7 +505,7 @@ select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w from - (select x.id, x.id as y from range(1,5) as x + (select x.id, x.id as y from range(1,6) as x union all select null, 42 union all select null, 43) ss window w as @@ -513,22 +514,22 @@ window w as -- Check overflow behavior for various integer sizes select x.id, last(x.id) over (order by x.id range between current row and 2147450884 following) -from range(32764, 32766) x; +from range(32764, 32767) x; select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) -from range(-32766, -32764) x; +from range(-32766, -32765) x; select x.id, last(x.id) over (order by x.id range between current row and 4 following) -from range(2147483644, 2147483646) x; +from range(2147483644, 2147483647) x; select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) -from range(-2147483646, -2147483644) x; +from range(-2147483646, -2147483645) x; select x.id, last(x.id) over (order by x.id range between current row and 4 following) -from range(9223372036854775804, 9223372036854775806) x; +from range(9223372036854775804, 9223372036854775807) x; select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) -from range(-9223372036854775806, -9223372036854775804) x; +from range(-9223372036854775806, -9223372036854775805) x; -- Test in_range for other numeric datatypes @@ -548,9 +549,9 @@ insert into numerics values (5, 1.12, 1.12, 1.12), (6, 2, 2, 2), (7, 100, 100, 100); ---(8, 'infinity', 'infinity', '1000'), ---(9, 'NaN', 'NaN', 'NaN'); ---(0, '-infinity', '-infinity', '-1000'), -- numeric type lacks infinities +-- (8, 'infinity', 'infinity', '1000'), +-- (9, 'NaN', 'NaN', 'NaN'); +-- (0, '-infinity', '-infinity', '-1000'), -- numeric type lacks infinities select id, f_float4, first(id) over w, last(id) over w @@ -731,46 +732,55 @@ insert into datetimes values -- exclude ties), salary, enroll_date from empsalary; -- GROUPS tests +-- [SPARK-28648] Adds support to `groups` unit type in window clauses -SELECT sum(unique1) over (order by four range between unbounded preceding and current row), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between unbounded preceding and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between current row and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between current row and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between 1 preceding and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between 1 following and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; --- [SPARK-28428] Spark `exclude` always expecting `()` --- SELECT sum(unique1) over (order by four range between 2 preceding and 1 following), +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), -- unique1, four -- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), -unique1, four -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), +-- unique1, four +-- FROM tenk1 WHERE unique1 < 10; -- [SPARK-28428] Spark `exclude` always expecting `()` --- SELECT sum(unique1) over (order by four range between 2 preceding and 1 following +-- SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following -- exclude current row), unique1, four -- FROM tenk1 WHERE unique1 < 10; @@ -784,34 +794,40 @@ FROM tenk1 WHERE unique1 < 10; -- exclude ties), unique1, four -- FROM tenk1 WHERE unique1 < 10; -SELECT sum(unique1) over (partition by ten - order by four range between 0 preceding and 0 following),unique1, four, ten -FROM tenk1 WHERE unique1 < 10; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- SELECT sum(unique1) over (partition by ten +-- order by four groups between 0 preceding and 0 following),unique1, four, ten +-- FROM tenk1 WHERE unique1 < 10; -- [SPARK-28428] Spark `exclude` always expecting `()` +-- [SPARK-28648] Adds support to `groups` unit type in window clauses -- SELECT sum(unique1) over (partition by ten --- order by four range between 0 preceding and 0 following exclude current row), unique1, four, ten +-- order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; -- [SPARK-28428] Spark `exclude` always expecting `()` +-- [SPARK-28648] Adds support to `groups` unit type in window clauses -- SELECT sum(unique1) over (partition by ten --- order by four range between 0 preceding and 0 following exclude group), unique1, four, ten +-- order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; -- [SPARK-28428] Spark `exclude` always expecting `()` +-- [SPARK-28648] Adds support to `groups` unit type in window clauses -- SELECT sum(unique1) over (partition by ten --- order by four range between 0 preceding and 0 following exclude ties), unique1, four, ten +-- order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten -- FROM tenk1 WHERE unique1 < 10; -- [SPARK-27951] ANSI SQL: NTH_VALUE function +-- [SPARK-28648] Adds support to `groups` unit type in window clauses -- select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; -- [SPARK-28508] Support for range frame+row frame in the same query --- select last(salary) over(order by enroll_date range between 1 preceding and 1 following), --- lag(salary) over(order by enroll_date range between 1 preceding and 1 following), +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- select last(salary) over(order by enroll_date groups between 1 preceding and 1 following), +-- lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), -- salary, enroll_date from empsalary; -- [SPARK-27951] ANSI SQL: NTH_VALUE function @@ -823,37 +839,38 @@ FROM tenk1 WHERE unique1 < 10; -- salary, enroll_date from empsalary; -- [SPARK-28428] Spark `exclude` always expecting `()` --- select last(salary) over(order by enroll_date range between 1 following and 3 following +-- select last(salary) over(order by enroll_date groups between 1 following and 3 following -- exclude group), --- lag(salary) over(order by enroll_date range between 1 following and 3 following exclude group), +-- lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), -- salary, enroll_date from empsalary; -- Show differences in offset interpretation between ROWS, RANGE, and GROUPS WITH cte (x) AS ( - SELECT * FROM range(1, 35, 2) + SELECT * FROM range(1, 36, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); WITH cte (x) AS ( - SELECT * FROM range(1, 35, 2) + SELECT * FROM range(1, 36, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); -WITH cte (x) AS ( - SELECT * FROM range(1, 35, 2) -) -SELECT x, (sum(x) over w) -FROM cte -WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- WITH cte (x) AS ( +-- SELECT * FROM range(1, 36, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); WITH cte (x) AS ( select 1 union all select 1 union all select 1 union all - SELECT * FROM range(5, 49, 2) + SELECT * FROM range(5, 50, 2) ) SELECT x, (sum(x) over w) FROM cte @@ -861,19 +878,20 @@ WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following); WITH cte (x) AS ( select 1 union all select 1 union all select 1 union all - SELECT * FROM range(5, 49, 2) + SELECT * FROM range(5, 50, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); -WITH cte (x) AS ( - select 1 union all select 1 union all select 1 union all - SELECT * FROM range(5, 49, 2) -) -SELECT x, (sum(x) over w) -FROM cte -WINDOW w AS (ORDER BY x range between 1 preceding and 1 following); +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- WITH cte (x) AS ( +-- select 1 union all select 1 union all select 1 union all +-- SELECT * FROM range(5, 50, 2) +-- ) +-- SELECT x, (sum(x) over w) +-- FROM cte +-- WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following); -- with UNION @@ -884,7 +902,7 @@ SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SEL create table t1 (f1 int, f2 int) using parquet; insert into t1 values (1,1),(1,2),(2,2); -select f1, sum(f1) over (partition by f1 order by f1 +select f1, sum(f1) over (partition by f1 range between 1 preceding and 1 following) from t1 where f1 = f2; -- error, must have order by @@ -905,9 +923,10 @@ select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2; -select f1, sum(f1) over (partition by f1, -f1 order by f2 range between 1 preceding and 1 following) -from t1 where f1 = f2; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- select f1, sum(f1) over (partition by f1, +-- groups between 1 preceding and 1 following) +-- from t1 where f1 = f2; -- Since EXPLAIN clause rely on host physical location, it is commented out -- explain @@ -915,17 +934,20 @@ from t1 where f1 = f2; -- range between 1 preceding and 1 following) -- from t1 where f1 = f2; -select f1, sum(f1) over (partition by f1 order by f2 -range between 1 preceding and 1 following) -from t1 where f1 = f2; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- select f1, sum(f1) over (partition by f1 order by f2 +-- groups between 1 preceding and 1 following) +-- from t1 where f1 = f2; -select f1, sum(f1) over (partition by f1, f1 order by f2 -range between 2 preceding and 1 preceding) -from t1 where f1 = f2; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- select f1, sum(f1) over (partition by f1, f1 order by f2 +-- groups between 2 preceding and 1 preceding) +-- from t1 where f1 = f2; -select f1, sum(f1) over (partition by f1, f2 order by f2 -range between 1 following and 2 following) -from t1 where f1 = f2; +-- [SPARK-28648] Adds support to `groups` unit type in window clauses +-- select f1, sum(f1) over (partition by f1, f2 order by f2 +-- groups between 1 following and 2 following) +-- from t1 where f1 = f2; -- ordering by a non-integer constant is allowed @@ -938,29 +960,30 @@ SELECT rank() OVER (ORDER BY length('abc')); -- some other errors SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; --- [SPARK-28506] not handling usage of group function and window function at some conditions --- SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; +SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; --- [SPARK-28506] not handling usage of group function and window function at some conditions --- SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; +SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; -- Since random() result may change due to seed issues, the behavior is actually unstable SELECT * FROM rank() OVER (ORDER BY random()); +-- Original query: DELETE FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10; SELECT * FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10; +-- Original query: DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random()); SELECT * FROM empsalary WHERE rank() OVER (ORDER BY random()); --- The original query currently outputs too many rows, so just count the output number -SELECT count(*) FROM (select count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1)); +-- [SPARK-28645] Throw an error on window redefinition +-- select count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); + +select rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; --- The original query currently outputs too many rows, so just count the output number -SELECT count(*) FROM (select rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1); +-- [SPARK-28646] Allow usage of `count` only for parameterless aggregate function +-- select count() OVER () FROM tenk1; --- The original query currently outputs too many rows, so just count the output number -SELECT count(*) FROM (select count() OVER () FROM tenk1); +-- The output is the expected one: `range` is not a window or aggregate function. +SELECT range(1, 100) OVER () FROM empsalary; --- [SPARK-28065] ntile only accepting positive (>0) values SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; -- [SPARK-27951] ANSI SQL: NTH_VALUE function @@ -1017,6 +1040,208 @@ SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; -- cleanup DROP TABLE empsalary; +-- test user-defined window function with named args and default args +-- CREATE FUNCTION nth_value_def(val anyelement, n integer = 1) RETURNS anyelement +-- LANGUAGE internal WINDOW IMMUTABLE STRICT AS 'window_nth_value'; + +-- SELECT nth_value_def(n := 2, val := ten) OVER (PARTITION BY four), ten, four +-- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s; + +-- SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four +-- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s; + +-- +-- Test the basic moving-aggregate machinery +-- + +-- create aggregates that record the series of transform calls (these are +-- intentionally not true inverses) + +-- CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS +-- $$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$ +-- LANGUAGE SQL IMMUTABLE; + +-- CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS +-- $$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$ +-- LANGUAGE SQL IMMUTABLE; + +-- CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS +-- $$ SELECT $1 || '-' || quote_nullable($2) $$ +-- LANGUAGE SQL IMMUTABLE; + +-- CREATE AGGREGATE logging_agg_nonstrict (anyelement) +-- ( +-- stype = text, +-- sfunc = logging_sfunc_nonstrict, +-- mstype = text, +-- msfunc = logging_msfunc_nonstrict, +-- minvfunc = logging_minvfunc_nonstrict +-- ); + +-- CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement) +-- ( +-- stype = text, +-- sfunc = logging_sfunc_nonstrict, +-- mstype = text, +-- msfunc = logging_msfunc_nonstrict, +-- minvfunc = logging_minvfunc_nonstrict, +-- initcond = 'I', +-- minitcond = 'MI' +-- ); + +-- CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS +-- $$ SELECT $1 || '*' || quote_nullable($2) $$ +-- LANGUAGE SQL STRICT IMMUTABLE; + +-- CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS +-- $$ SELECT $1 || '+' || quote_nullable($2) $$ +-- LANGUAGE SQL STRICT IMMUTABLE; + +-- CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS +-- $$ SELECT $1 || '-' || quote_nullable($2) $$ +-- LANGUAGE SQL STRICT IMMUTABLE; + +-- CREATE AGGREGATE logging_agg_strict (text) +-- ( +-- stype = text, +-- sfunc = logging_sfunc_strict, +-- mstype = text, +-- msfunc = logging_msfunc_strict, +-- minvfunc = logging_minvfunc_strict +-- ); + +-- CREATE AGGREGATE logging_agg_strict_initcond (anyelement) +-- ( +-- stype = text, +-- sfunc = logging_sfunc_strict, +-- mstype = text, +-- msfunc = logging_msfunc_strict, +-- minvfunc = logging_minvfunc_strict, +-- initcond = 'I', +-- minitcond = 'MI' +-- ); + +-- test strict and non-strict cases +-- SELECT +-- p::text || ',' || i::text || ':' || COALESCE(v::text, 'NULL') AS row, +-- logging_agg_nonstrict(v) over wnd as nstrict, +-- logging_agg_nonstrict_initcond(v) over wnd as nstrict_init, +-- logging_agg_strict(v::text) over wnd as strict, +-- logging_agg_strict_initcond(v) over wnd as strict_init +-- FROM (VALUES +-- (1, 1, NULL), +-- (1, 2, 'a'), +-- (1, 3, 'b'), +-- (1, 4, NULL), +-- (1, 5, NULL), +-- (1, 6, 'c'), +-- (2, 1, NULL), +-- (2, 2, 'x'), +-- (3, 1, 'z') +-- ) AS t(p, i, v) +-- WINDOW wnd AS (PARTITION BY P ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +-- ORDER BY p, i; + +-- and again, but with filter +-- SELECT +-- p::text || ',' || i::text || ':' || +-- CASE WHEN f THEN COALESCE(v::text, 'NULL') ELSE '-' END as row, +-- logging_agg_nonstrict(v) filter(where f) over wnd as nstrict_filt, +-- logging_agg_nonstrict_initcond(v) filter(where f) over wnd as nstrict_init_filt, +-- logging_agg_strict(v::text) filter(where f) over wnd as strict_filt, +-- logging_agg_strict_initcond(v) filter(where f) over wnd as strict_init_filt +-- FROM (VALUES +-- (1, 1, true, NULL), +-- (1, 2, false, 'a'), +-- (1, 3, true, 'b'), +-- (1, 4, false, NULL), +-- (1, 5, false, NULL), +-- (1, 6, false, 'c'), +-- (2, 1, false, NULL), +-- (2, 2, true, 'x'), +-- (3, 1, true, 'z') +-- ) AS t(p, i, f, v) +-- WINDOW wnd AS (PARTITION BY p ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +-- ORDER BY p, i; + +-- test that volatile arguments disable moving-aggregate mode +-- SELECT +-- i::text || ':' || COALESCE(v::text, 'NULL') as row, +-- logging_agg_strict(v::text) +-- over wnd as inverse, +-- logging_agg_strict(v::text || CASE WHEN random() < 0 then '?' ELSE '' END) +-- over wnd as noinverse +-- FROM (VALUES +-- (1, 'a'), +-- (2, 'b'), +-- (3, 'c') +-- ) AS t(i, v) +-- WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +-- ORDER BY i; + +-- SELECT +-- i::text || ':' || COALESCE(v::text, 'NULL') as row, +-- logging_agg_strict(v::text) filter(where true) +-- over wnd as inverse, +-- logging_agg_strict(v::text) filter(where random() >= 0) +-- over wnd as noinverse +-- FROM (VALUES +-- (1, 'a'), +-- (2, 'b'), +-- (3, 'c') +-- ) AS t(i, v) +-- WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +-- ORDER BY i; + +-- test that non-overlapping windows don't use inverse transitions +-- SELECT +-- logging_agg_strict(v::text) OVER wnd +-- FROM (VALUES +-- (1, 'a'), +-- (2, 'b'), +-- (3, 'c') +-- ) AS t(i, v) +-- WINDOW wnd AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) +-- ORDER BY i; + +-- test that returning NULL from the inverse transition functions +-- restarts the aggregation from scratch. The second aggregate is supposed +-- to test cases where only some aggregates restart, the third one checks +-- that one aggregate restarting doesn't cause others to restart. + +-- CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS +-- $$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$ +-- LANGUAGE SQL STRICT; + +-- CREATE AGGREGATE sum_int_randomrestart (int4) +-- ( +-- stype = int4, +-- sfunc = int4pl, +-- mstype = int4, +-- msfunc = int4pl, +-- minvfunc = sum_int_randrestart_minvfunc +-- ); + +-- WITH +-- vs AS ( +-- SELECT i, (random() * 100)::int4 AS v +-- FROM generate_series(1, 100) AS i +-- ), +-- sum_following AS ( +-- SELECT i, SUM(v) OVER +-- (ORDER BY i DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS s +-- FROM vs +-- ) +-- SELECT DISTINCT +-- sum_following.s = sum_int_randomrestart(v) OVER fwd AS eq1, +-- -sum_following.s = sum_int_randomrestart(-v) OVER fwd AS eq2, +-- 100*3+(vs.i-1)*3 = length(logging_agg_nonstrict(''::text) OVER fwd) AS eq3 +-- FROM vs +-- JOIN sum_following ON sum_following.i = vs.i +-- WINDOW fwd AS ( +-- ORDER BY vs.i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING +-- ); + -- -- Test various built-in aggregates that have moving-aggregate support -- @@ -1141,6 +1366,7 @@ SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWI SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n); +-- test that inverse transition functions work with various frame options SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v); diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 2c6a780eb8415..8839038c7df87 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 162 +-- Number of queries: 148 -- !query 0 @@ -904,46 +904,40 @@ struct -- !query 51 output +org.apache.spark.sql.catalyst.parser.ParseException + +mismatched input '(' expecting {, ',', 'CLUSTER', 'DISTRIBUTE', 'EXCEPT', 'FROM', 'GROUP', 'HAVING', 'INTERSECT', 'LATERAL', 'LIMIT', 'ORDER', 'MINUS', 'SORT', 'UNION', 'WHERE', 'WINDOW', '-'}(line 1, pos 25) +== SQL == +SELECT sum(unique1) over (w range between current row and unbounded following), +-------------------------^^^ + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) -- !query 52 -SELECT * FROM v_window +CREATE TEMP VIEW v_window AS +SELECT i.id, sum(i.id) over (order by i.id rows between 1 preceding and 1 following) as sum_rows +FROM range(1, 11) i -- !query 52 schema -struct --- !query 52 output -1 3 -2 6 -3 9 -4 12 -5 15 -6 18 -7 21 -8 24 -9 17 - - --- !query 53 -CREATE OR REPLACE TEMP VIEW v_window AS -SELECT i.id, sum(i.id) over (order by i.id range between 1 preceding and 1 following) as sum_rows FROM range(1, 10) i --- !query 53 schema struct<> --- !query 53 output +-- !query 52 output --- !query 54 +-- !query 53 SELECT * FROM v_window --- !query 54 schema +-- !query 53 schema struct --- !query 54 output +-- !query 53 output 1 3 +10 19 2 6 3 9 4 12 @@ -951,24 +945,24 @@ struct 6 18 7 21 8 24 -9 17 +9 27 --- !query 55 +-- !query 54 DROP VIEW v_window --- !query 55 schema +-- !query 54 schema struct<> --- !query 55 output +-- !query 54 output --- !query 56 +-- !query 55 SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 56 schema +-- !query 55 schema struct --- !query 56 output +-- !query 55 output 12 1 1 12 5 1 12 9 1 @@ -981,13 +975,13 @@ NULL 4 0 NULL 8 0 --- !query 57 +-- !query 56 SELECT sum(unique1) over (order by four desc range between 2 preceding and 1 preceding), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 57 schema +-- !query 56 schema struct --- !query 57 output +-- !query 56 output 10 2 2 10 6 2 18 1 1 @@ -1000,13 +994,13 @@ NULL 3 3 NULL 7 3 --- !query 58 +-- !query 57 SELECT sum(unique1) over (partition by four order by unique1 range between 5 preceding and 6 following), unique1, four FROM tenk1 WHERE unique1 < 10 --- !query 58 schema +-- !query 57 schema struct --- !query 58 output +-- !query 57 output 10 3 3 10 7 3 12 4 0 @@ -1019,12 +1013,23 @@ struct +-- !query 58 output +org.apache.spark.sql.AnalysisException +Window Frame specifiedwindowframe(RangeFrame, -1000, 1000) must match the required frame specifiedwindowframe(RowFrame, -1, -1); + + -- !query 59 select ss.id, ss.y, first(ss.y) over w, last(ss.y) over w from - (select x.id, x.id as y from range(1,5) as x + (select x.id, x.id as y from range(1,6) as x union all select null, 42 union all select null, 43) ss window w as @@ -1034,8 +1039,9 @@ struct -- !query 63 output -32764 32765 -32765 32765 +32764 32766 +32765 32766 +32766 32766 -- !query 64 select x.id, last(x.id) over (order by x.id desc range between current row and 2147450885 following) -from range(-32766, -32764) x +from range(-32766, -32765) x -- !query 64 schema struct -- !query 64 output --32765 -32766 -32766 -32766 -- !query 65 select x.id, last(x.id) over (order by x.id range between current row and 4 following) -from range(2147483644, 2147483646) x +from range(2147483644, 2147483647) x -- !query 65 schema struct -- !query 65 output -2147483644 2147483645 -2147483645 2147483645 +2147483644 2147483646 +2147483645 2147483646 +2147483646 2147483646 -- !query 66 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) -from range(-2147483646, -2147483644) x +from range(-2147483646, -2147483645) x -- !query 66 schema struct -- !query 66 output --2147483645 -2147483646 -2147483646 -2147483646 -- !query 67 select x.id, last(x.id) over (order by x.id range between current row and 4 following) -from range(9223372036854775804, 9223372036854775806) x +from range(9223372036854775804, 9223372036854775807) x -- !query 67 schema struct -- !query 67 output 9223372036854775804 NULL 9223372036854775805 NULL +9223372036854775806 NULL -- !query 68 select x.id, last(x.id) over (order by x.id desc range between current row and 5 following) -from range(-9223372036854775806, -9223372036854775804) x +from range(-9223372036854775806, -9223372036854775805) x -- !query 68 schema struct -- !query 68 output --9223372036854775805 NULL -9223372036854775806 NULL @@ -1438,186 +1447,15 @@ struct<> -- !query 85 -SELECT sum(unique1) over (order by four range between unbounded preceding and current row), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 85 schema -struct --- !query 85 output -12 0 0 -12 4 0 -12 8 0 -27 1 1 -27 5 1 -27 9 1 -35 2 2 -35 6 2 -45 3 3 -45 7 3 - - --- !query 86 -SELECT sum(unique1) over (order by four range between unbounded preceding and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 86 schema -struct --- !query 86 output -45 0 0 -45 1 1 -45 2 2 -45 3 3 -45 4 0 -45 5 1 -45 6 2 -45 7 3 -45 8 0 -45 9 1 - - --- !query 87 -SELECT sum(unique1) over (order by four range between current row and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 87 schema -struct --- !query 87 output -10 3 3 -10 7 3 -18 2 2 -18 6 2 -33 1 1 -33 5 1 -33 9 1 -45 0 0 -45 4 0 -45 8 0 - - --- !query 88 -SELECT sum(unique1) over (order by four range between 1 preceding and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 88 schema -struct --- !query 88 output -18 3 3 -18 7 3 -33 2 2 -33 6 2 -45 0 0 -45 1 1 -45 4 0 -45 5 1 -45 8 0 -45 9 1 - - --- !query 89 -SELECT sum(unique1) over (order by four range between 1 following and unbounded following), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 89 schema -struct --- !query 89 output -10 2 2 -10 6 2 -18 1 1 -18 5 1 -18 9 1 -33 0 0 -33 4 0 -33 8 0 -NULL 3 3 -NULL 7 3 - - --- !query 90 -SELECT sum(unique1) over (order by four range between unbounded preceding and 2 following), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 90 schema -struct --- !query 90 output -35 0 0 -35 4 0 -35 8 0 -45 1 1 -45 2 2 -45 3 3 -45 5 1 -45 6 2 -45 7 3 -45 9 1 - - --- !query 91 -SELECT sum(unique1) over (order by four range between 2 preceding and 1 preceding), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 91 schema -struct --- !query 91 output -12 1 1 -12 5 1 -12 9 1 -23 3 3 -23 7 3 -27 2 2 -27 6 2 -NULL 0 0 -NULL 4 0 -NULL 8 0 - - --- !query 92 -SELECT sum(unique1) over (order by four range between 0 preceding and 0 following), -unique1, four -FROM tenk1 WHERE unique1 < 10 --- !query 92 schema -struct --- !query 92 output -10 3 3 -10 7 3 -12 0 0 -12 4 0 -12 8 0 -15 1 1 -15 5 1 -15 9 1 -8 2 2 -8 6 2 - - --- !query 93 -SELECT sum(unique1) over (partition by ten - order by four range between 0 preceding and 0 following),unique1, four, ten -FROM tenk1 WHERE unique1 < 10 --- !query 93 schema -struct --- !query 93 output -0 0 0 0 -1 1 1 1 -2 2 2 2 -3 3 3 3 -4 4 0 4 -5 5 1 5 -6 6 2 6 -7 7 3 7 -8 8 0 8 -9 9 1 9 - - --- !query 94 WITH cte (x) AS ( - SELECT * FROM range(1, 35, 2) + SELECT * FROM range(1, 36, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) --- !query 94 schema +-- !query 85 schema struct --- !query 94 output +-- !query 85 output 1 4 11 33 13 39 @@ -1631,51 +1469,23 @@ struct --- !query 95 output -1 1 -11 11 -13 13 -15 15 -17 17 -19 19 -21 21 -23 23 -25 25 -27 27 -29 29 -3 3 -31 31 -33 33 -5 5 -7 7 -9 9 - - --- !query 96 +-- !query 86 WITH cte (x) AS ( - SELECT * FROM range(1, 35, 2) + SELECT * FROM range(1, 36, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) --- !query 96 schema +-- !query 86 schema struct --- !query 96 output +-- !query 86 output 1 1 11 11 13 13 @@ -1690,22 +1500,23 @@ struct --- !query 97 output +-- !query 87 output 1 2 1 3 1 7 @@ -1727,23 +1538,24 @@ struct --- !query 98 output +-- !query 88 output 1 3 1 3 1 3 @@ -1766,175 +1578,118 @@ struct --- !query 99 output -1 3 -1 3 -1 3 -11 11 -13 13 -15 15 -17 17 -19 19 -21 21 -23 23 -25 25 -27 27 -29 29 -31 31 -33 33 -35 35 -37 37 -39 39 -41 41 -43 43 -45 45 -47 47 -5 5 -7 7 -9 9 - - --- !query 100 +-- !query 89 SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0 --- !query 100 schema +-- !query 89 schema struct --- !query 100 output +-- !query 89 output --- !query 101 +-- !query 90 create table t1 (f1 int, f2 int) using parquet --- !query 101 schema +-- !query 90 schema struct<> --- !query 101 output +-- !query 90 output --- !query 102 +-- !query 91 insert into t1 values (1,1),(1,2),(2,2) --- !query 102 schema +-- !query 91 schema struct<> --- !query 102 output +-- !query 91 output --- !query 103 -select f1, sum(f1) over (partition by f1 order by f1 +-- !query 92 +select f1, sum(f1) over (partition by f1 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 103 schema -struct --- !query 103 output -1 1 -2 2 +-- !query 92 schema +struct<> +-- !query 92 output +org.apache.spark.sql.AnalysisException +cannot resolve '(PARTITION BY default.t1.`f1` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)' due to data type mismatch: A range window frame cannot be used in an unordered window specification.; line 1 pos 24 --- !query 104 +-- !query 93 -- error, must have order by select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 104 schema -struct --- !query 104 output -1 NULL -2 NULL - - --- !query 105 -select f1, sum(f1) over (partition by f1, f2 order by f2 -range between 1 following and 2 following) -from t1 where f1 = f2 --- !query 105 schema -struct --- !query 105 output -1 NULL -2 NULL - - --- !query 106 -select f1, sum(f1) over (partition by f1, -f1 order by f2 range between 1 preceding and 1 following) -from t1 where f1 = f2 --- !query 106 schema -struct --- !query 106 output -1 1 -2 2 - - --- !query 107 -select f1, sum(f1) over (partition by f1 order by f2 -range between 1 preceding and 1 following) -from t1 where f1 = f2 --- !query 107 schema -struct --- !query 107 output -1 1 -2 2 - - --- !query 108 -select f1, sum(f1) over (partition by f1, f1 order by f2 -range between 2 preceding and 1 preceding) -from t1 where f1 = f2 --- !query 108 schema +-- !query 93 schema struct --- !query 108 output +-- !query 93 output 1 NULL 2 NULL --- !query 109 +-- !query 94 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 109 schema +-- !query 94 schema struct --- !query 109 output +-- !query 94 output 1 NULL 2 NULL --- !query 110 +-- !query 95 SELECT rank() OVER (ORDER BY length('abc')) --- !query 110 schema +-- !query 95 schema struct --- !query 110 output +-- !query 95 output 1 --- !query 111 +-- !query 96 SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10 --- !query 111 schema +-- !query 96 schema struct<> --- !query 111 output +-- !query 96 output org.apache.spark.sql.AnalysisException It is not allowed to use window functions inside WHERE and HAVING clauses; --- !query 112 +-- !query 97 +SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10 +-- !query 97 schema +struct<> +-- !query 97 output +org.apache.spark.sql.AnalysisException + +The query operator `Join` contains one or more unsupported +expression types Aggregate, Window or Generate. +Invalid expressions: [row_number() OVER (ORDER BY default.empsalary.`salary` ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)]; + + +-- !query 98 +SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1 +-- !query 98 schema +struct<> +-- !query 98 output +org.apache.spark.sql.AnalysisException + +The query operator `Aggregate` contains one or more unsupported +expression types Aggregate, Window or Generate. +Invalid expressions: [RANK() OVER (ORDER BY 1 ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)]; + + +-- !query 99 SELECT * FROM rank() OVER (ORDER BY random()) --- !query 112 schema +-- !query 99 schema struct<> --- !query 112 output +-- !query 99 output org.apache.spark.sql.catalyst.parser.ParseException no viable alternative at input 'ORDER'(line 1, pos 27) @@ -1944,202 +1699,201 @@ SELECT * FROM rank() OVER (ORDER BY random()) ---------------------------^^^ --- !query 113 +-- !query 100 SELECT * FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10 --- !query 113 schema +-- !query 100 schema struct<> --- !query 113 output +-- !query 100 output org.apache.spark.sql.AnalysisException It is not allowed to use window functions inside WHERE and HAVING clauses; --- !query 114 +-- !query 101 SELECT * FROM empsalary WHERE rank() OVER (ORDER BY random()) --- !query 114 schema +-- !query 101 schema struct<> --- !query 114 output +-- !query 101 output org.apache.spark.sql.AnalysisException It is not allowed to use window functions inside WHERE and HAVING clauses; --- !query 115 -SELECT count(*) FROM (select count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1)) --- !query 115 schema -struct --- !query 115 output -10000 +-- !query 102 +select rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1 +-- !query 102 schema +struct<> +-- !query 102 output +org.apache.spark.sql.catalyst.parser.ParseException +no viable alternative at input 'ORDER'(line 1, pos 39) --- !query 116 -SELECT count(*) FROM (select rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1) --- !query 116 schema -struct --- !query 116 output -10000 +== SQL == +select rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1 +---------------------------------------^^^ --- !query 117 -SELECT count(*) FROM (select count() OVER () FROM tenk1) --- !query 117 schema -struct --- !query 117 output -10000 +-- !query 103 +SELECT range(1, 100) OVER () FROM empsalary +-- !query 103 schema +struct<> +-- !query 103 output +org.apache.spark.sql.AnalysisException +Undefined function: 'range'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 7 --- !query 118 +-- !query 104 SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 --- !query 118 schema +-- !query 104 schema struct<> --- !query 118 output +-- !query 104 output org.apache.spark.sql.AnalysisException cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; line 1 pos 7 --- !query 119 +-- !query 105 DROP TABLE empsalary --- !query 119 schema +-- !query 105 schema struct<> --- !query 119 output +-- !query 105 output --- !query 120 +-- !query 106 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 120 schema +-- !query 106 schema struct --- !query 120 output +-- !query 106 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 121 +-- !query 107 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 121 schema +-- !query 107 schema struct --- !query 121 output +-- !query 107 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 122 +-- !query 108 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 122 schema +-- !query 108 schema struct --- !query 122 output +-- !query 108 output 1 1.5 2 2.0 3 NULL 4 NULL --- !query 123 +-- !query 109 SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) --- !query 123 schema +-- !query 109 schema struct --- !query 123 output +-- !query 109 output 1 2 2 2.5 3 NULL 4 NULL --- !query 124 +-- !query 110 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 124 schema +-- !query 110 schema struct --- !query 124 output +-- !query 110 output 1 3 2 2 3 NULL 4 NULL --- !query 125 +-- !query 111 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 125 schema +-- !query 111 schema struct --- !query 125 output +-- !query 111 output 1 3 2 2 3 NULL 4 NULL --- !query 126 +-- !query 112 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 126 schema +-- !query 112 schema struct --- !query 126 output +-- !query 112 output 1 3 2 2 3 NULL 4 NULL --- !query 127 +-- !query 113 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) --- !query 127 schema +-- !query 113 schema struct --- !query 127 output +-- !query 113 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 128 +-- !query 114 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 128 schema +-- !query 114 schema struct --- !query 128 output +-- !query 114 output 3 5 6.01 --- !query 129 +-- !query 115 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 129 schema +-- !query 115 schema struct --- !query 129 output +-- !query 115 output 1 2 2 1 3 0 4 0 --- !query 130 +-- !query 116 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 130 schema +-- !query 116 schema struct --- !query 130 output +-- !query 116 output 1 4 2 3 3 2 4 1 --- !query 131 +-- !query 117 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 131 schema +-- !query 117 schema struct --- !query 131 output +-- !query 117 output 0.0 11266.666666666666 13868.750000000002 @@ -2147,12 +1901,12 @@ struct --- !query 132 output +-- !query 118 output 0.0 11266.666666666666 13868.750000000002 @@ -2160,12 +1914,12 @@ struct --- !query 133 output +-- !query 119 output 0.0 11266.666666666666 13868.750000000002 @@ -2173,12 +1927,12 @@ struct --- !query 134 output +-- !query 120 output 0.0 11266.666666666666 13868.750000000002 @@ -2186,12 +1940,12 @@ struct --- !query 135 output +-- !query 121 output 16900.0 18491.666666666668 27129.999999999996 @@ -2199,12 +1953,12 @@ struct --- !query 136 output +-- !query 122 output 16900.0 18491.666666666668 27129.999999999996 @@ -2212,12 +1966,12 @@ struct --- !query 137 output +-- !query 123 output 16900.0 18491.666666666668 27129.999999999996 @@ -2225,12 +1979,12 @@ struct --- !query 138 output +-- !query 124 output 16900.0 18491.666666666668 27129.999999999996 @@ -2238,12 +1992,12 @@ struct --- !query 139 output +-- !query 125 output 16900.0 18491.666666666668 27129.999999999996 @@ -2251,12 +2005,12 @@ struct --- !query 140 output +-- !query 126 output 16900.0 18491.666666666668 27129.999999999996 @@ -2264,12 +2018,12 @@ struct --- !query 141 output +-- !query 127 output 16900.0 18491.666666666668 27129.999999999996 @@ -2277,12 +2031,12 @@ struct --- !query 142 output +-- !query 128 output 16900.0 18491.666666666668 27129.999999999996 @@ -2290,12 +2044,12 @@ struct --- !query 143 output +-- !query 129 output 0.0 106.14455552060438 117.76565713313879 @@ -2304,12 +2058,12 @@ struct --- !query 144 output +-- !query 130 output 0.0 106.14455552060438 117.76565713313879 @@ -2318,12 +2072,12 @@ struct --- !query 145 output +-- !query 131 output 0.0 106.14455552060438 117.76565713313879 @@ -2332,12 +2086,12 @@ struct --- !query 146 output +-- !query 132 output 0.0 106.14455552060438 117.76565713313879 @@ -2346,12 +2100,12 @@ struct --- !query 147 output +-- !query 133 output 130.0 135.9840676942217 164.7118696390761 @@ -2360,12 +2114,12 @@ struct --- !query 148 output +-- !query 134 output 130.0 135.9840676942217 164.7118696390761 @@ -2374,12 +2128,12 @@ struct --- !query 149 output +-- !query 135 output 130.0 135.9840676942217 164.7118696390761 @@ -2388,12 +2142,12 @@ struct --- !query 150 output +-- !query 136 output 130.0 135.9840676942217 164.7118696390761 @@ -2402,12 +2156,12 @@ struct --- !query 151 output +-- !query 137 output 130.0 135.9840676942217 164.7118696390761 @@ -2416,12 +2170,12 @@ struct --- !query 152 output +-- !query 138 output 130.0 135.9840676942217 164.7118696390761 @@ -2430,12 +2184,12 @@ struct --- !query 153 output +-- !query 139 output 130.0 135.9840676942217 164.7118696390761 @@ -2444,12 +2198,12 @@ struct --- !query 154 output +-- !query 140 output 130.0 135.9840676942217 164.7118696390761 @@ -2458,69 +2212,69 @@ struct --- !query 155 output +-- !query 141 output 1 1 2 2 3 NULL 4 NULL --- !query 156 +-- !query 142 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 156 schema +-- !query 142 schema struct --- !query 156 output +-- !query 142 output 1 3 2 2 3 NULL 4 NULL --- !query 157 +-- !query 143 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 157 schema +-- !query 143 schema struct --- !query 157 output +-- !query 143 output 1 3 2 6 3 9 4 7 --- !query 158 +-- !query 144 drop table numerics --- !query 158 schema +-- !query 144 schema struct<> --- !query 158 output +-- !query 144 output --- !query 159 +-- !query 145 drop table t1 --- !query 159 schema +-- !query 145 schema struct<> --- !query 159 output +-- !query 145 output --- !query 160 +-- !query 146 drop view int4_tbl --- !query 160 schema +-- !query 146 schema struct<> --- !query 160 output +-- !query 146 output --- !query 161 +-- !query 147 drop table datetimes --- !query 161 schema +-- !query 147 schema struct<> --- !query 161 output +-- !query 147 output From 826708d1e7a8a61a356dc5318d9097feda35acab Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Wed, 14 Aug 2019 16:53:26 -0300 Subject: [PATCH 24/25] update new PRs Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 20 +- .../sql-tests/results/pgSQL/window.sql.out | 533 ++++++++---------- 2 files changed, 260 insertions(+), 293 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 7360cb96a0f62..9c1a382cc807c 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -540,7 +540,6 @@ create table numerics ( f_numeric int ) using parquet; --- [SPARK-27768] Infinity, -Infinity, NaN should be recognized in a case insensitive manner insert into numerics values (1, -3, -3, -3), (2, -1, -1, -1), @@ -548,11 +547,10 @@ insert into numerics values (4, 1.1, 1.1, 1.1), (5, 1.12, 1.12, 1.12), (6, 2, 2, 2), -(7, 100, 100, 100); --- (8, 'infinity', 'infinity', '1000'), --- (9, 'NaN', 'NaN', 'NaN'); --- (0, '-infinity', '-infinity', '-1000'), -- numeric type lacks infinities - +(7, 100, 100, 100) +(8, 'infinity', 'infinity', '1000'), +(9, 'NaN', 'NaN', 'NaN'); +(0, '-infinity', '-infinity', '-1000'); -- numeric type lacks infinities select id, f_float4, first(id) over w, last(id) over w from numerics @@ -1377,10 +1375,12 @@ SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v); -- ensure aggregate over numeric properly recovers from NaN values --- [SPARK-27768] Infinity, -Infinity, NaN should be recognized in a case insensitive manner --- SELECT a, b, --- SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) --- FROM (VALUES(1,1),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b); +SELECT a, b, + SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +FROM (VALUES(1,1),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b); + +select f_float4, sum(f_float4) over (order by f_float8 rows between 1 + preceding and current row) from numerics; -- It might be tempting for someone to add an inverse trans function for -- float and double precision. This should not be done as it can give incorrect diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 8839038c7df87..9f9a1e162204e 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 148 +-- Number of queries: 151 -- !query 0 @@ -1194,184 +1194,140 @@ insert into numerics values (5, 1.12, 1.12, 1.12), (6, 2, 2, 2), (7, 100, 100, 100) +(8, 'infinity', 'infinity', '1000'), +(9, 'NaN', 'NaN', 'NaN') -- !query 70 schema struct<> -- !query 70 output +org.apache.spark.sql.catalyst.parser.ParseException +mismatched input '(' expecting {, ',', '.', '[', 'ADD', 'AFTER', 'ALL', 'ALTER', 'ANALYZE', 'AND', 'ANY', 'ARCHIVE', 'ARRAY', 'AS', 'ASC', 'AT', 'AUTHORIZATION', 'BETWEEN', 'BOTH', 'BUCKET', 'BUCKETS', 'BY', 'CACHE', 'CASCADE', 'CASE', 'CAST', 'CHANGE', 'CHECK', 'CLEAR', 'CLUSTER', 'CLUSTERED', 'CODEGEN', 'COLLATE', 'COLLECTION', 'COLUMN', 'COLUMNS', 'COMMENT', 'COMMIT', 'COMPACT', 'COMPACTIONS', 'COMPUTE', 'CONCATENATE', 'CONSTRAINT', 'COST', 'CREATE', 'CUBE', 'CURRENT', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'DATA', 'DATABASE', DATABASES, 'DAY', 'DAYS', 'DBPROPERTIES', 'DEFINED', 'DELETE', 'DELIMITED', 'DESC', 'DESCRIBE', 'DFS', 'DIRECTORIES', 'DIRECTORY', 'DISTINCT', 'DISTRIBUTE', 'DROP', 'ELSE', 'END', 'ESCAPED', 'EXCEPT', 'EXCHANGE', 'EXISTS', 'EXPLAIN', 'EXPORT', 'EXTENDED', 'EXTERNAL', 'EXTRACT', 'FALSE', 'FETCH', 'FIELDS', 'FILEFORMAT', 'FIRST', 'FIRST_VALUE', 'FOLLOWING', 'FOR', 'FOREIGN', 'FORMAT', 'FORMATTED', 'FROM', 'FUNCTION', 'FUNCTIONS', 'GLOBAL', 'GRANT', 'GROUP', 'GROUPING', 'HAVING', 'HOUR', 'HOURS', 'IF', 'IGNORE', 'IMPORT', 'IN', 'INDEX', 'INDEXES', 'INPATH', 'INPUTFORMAT', 'INSERT', 'INTERSECT', 'INTERVAL', 'INTO', 'IS', 'ITEMS', 'KEYS', 'LAST', 'LAST_VALUE', 'LATERAL', 'LAZY', 'LEADING', 'LIKE', 'LIMIT', 'LINES', 'LIST', 'LOAD', 'LOCAL', 'LOCATION', 'LOCK', 'LOCKS', 'LOGICAL', 'MACRO', 'MAP', 'MICROSECOND', 'MICROSECONDS', 'MILLISECOND', 'MILLISECONDS', 'MINUTE', 'MINUTES', 'MONTH', 'MONTHS', 'MSCK', 'NO', NOT, 'NULL', 'NULLS', 'OF', 'ONLY', 'OPTION', 'OPTIONS', 'OR', 'ORDER', 'OUT', 'OUTER', 'OUTPUTFORMAT', 'OVER', 'OVERLAPS', 'OVERLAY', 'OVERWRITE', 'PARTITION', 'PARTITIONED', 'PARTITIONS', 'PERCENT', 'PIVOT', 'PLACING', 'POSITION', 'PRECEDING', 'PRIMARY', 'PRINCIPALS', 'PURGE', 'QUERY', 'RANGE', 'RECORDREADER', 'RECORDWRITER', 'RECOVER', 'REDUCE', 'REFERENCES', 'REFRESH', 'RENAME', 'REPAIR', 'REPLACE', 'RESET', 'RESPECT', 'RESTRICT', 'REVOKE', RLIKE, 'ROLE', 'ROLES', 'ROLLBACK', 'ROLLUP', 'ROW', 'ROWS', 'SCHEMA', 'SECOND', 'SECONDS', 'SELECT', 'SEPARATED', 'SERDE', 'SERDEPROPERTIES', 'SESSION_USER', 'SET', 'MINUS', 'SETS', 'SHOW', 'SKEWED', 'SOME', 'SORT', 'SORTED', 'START', 'STATISTICS', 'STORED', 'STRATIFY', 'STRUCT', 'SUBSTR', 'SUBSTRING', 'TABLE', 'TABLES', 'TABLESAMPLE', 'TBLPROPERTIES', TEMPORARY, 'TERMINATED', 'THEN', 'TO', 'TOUCH', 'TRAILING', 'TRANSACTION', 'TRANSACTIONS', 'TRANSFORM', 'TRIM', 'TRUE', 'TRUNCATE', 'TYPE', 'UNARCHIVE', 'UNBOUNDED', 'UNCACHE', 'UNION', 'UNIQUE', 'UNKNOWN', 'UNLOCK', 'UNSET', 'USE', 'USER', 'VALUES', 'VIEW', 'WEEK', 'WEEKS', 'WHEN', 'WHERE', 'WINDOW', 'WITH', 'YEAR', 'YEARS', EQ, '<=>', '<>', '!=', '<', LTE, '>', GTE, '+', '-', '*', '/', '%', 'DIV', '&', '|', '||', '^', IDENTIFIER, BACKQUOTED_IDENTIFIER}(line 9, pos 0) + +== SQL == +insert into numerics values +(1, -3, -3, -3), +(2, -1, -1, -1), +(3, 0, 0, 0), +(4, 1.1, 1.1, 1.1), +(5, 1.12, 1.12, 1.12), +(6, 2, 2, 2), +(7, 100, 100, 100) +(8, 'infinity', 'infinity', '1000'), +^^^ +(9, 'NaN', 'NaN', 'NaN') -- !query 71 -select id, f_float4, first(id) over w, last(id) over w -from numerics -window w as (order by f_float4 range between - 1 preceding and 1 following) +(0, '-infinity', '-infinity', '-1000') -- !query 71 schema -struct +struct<> -- !query 71 output -1 -3.0 1 1 -2 -1.0 2 3 -3 0.0 2 3 -4 1.1 4 6 -5 1.12 4 6 -6 2.0 4 6 -7 100.0 7 7 +org.apache.spark.sql.catalyst.parser.ParseException + +mismatched input '0' expecting {'(', 'FROM', 'MAP', 'REDUCE', 'SELECT', 'TABLE', 'VALUES', 'WITH'}(line 1, pos 1) + +== SQL == +(0, '-infinity', '-infinity', '-1000') +-^^^ -- !query 72 select id, f_float4, first(id) over w, last(id) over w from numerics window w as (order by f_float4 range between - 1 preceding and 1.1 following) + 1 preceding and 1 following) -- !query 72 schema -struct +struct -- !query 72 output -1 -3.0 1 1 -2 -1.0 2 3 -3 0.0 2 4 -4 1.1 4 6 -5 1.12 4 6 -6 2.0 4 6 -7 100.0 7 7 + -- !query 73 select id, f_float4, first(id) over w, last(id) over w from numerics window w as (order by f_float4 range between - 'inf' preceding and 'inf' following) + 1 preceding and 1.1 following) -- !query 73 schema -struct +struct -- !query 73 output -1 -3.0 NULL NULL -2 -1.0 NULL NULL -3 0.0 NULL NULL -4 1.1 NULL NULL -5 1.12 NULL NULL -6 2.0 NULL NULL -7 100.0 NULL NULL + -- !query 74 select id, f_float4, first(id) over w, last(id) over w from numerics window w as (order by f_float4 range between - 1.1 preceding and 'NaN' following) + 'inf' preceding and 'inf' following) -- !query 74 schema -struct +struct -- !query 74 output -1 -3.0 1 7 -2 -1.0 2 7 -3 0.0 2 7 -4 1.1 3 7 -5 1.12 4 7 -6 2.0 4 7 -7 100.0 7 7 --- !query 75 --- error, NaN disallowed -select id, f_float8, first(id) over w, last(id) over w +-- !query 75 +select id, f_float4, first(id) over w, last(id) over w from numerics -window w as (order by f_float8 range between - 1 preceding and 1 following) +window w as (order by f_float4 range between + 1.1 preceding and 'NaN' following) -- !query 75 schema -struct +struct -- !query 75 output -1 -3.0 1 1 -2 -1.0 2 3 -3 0.0 2 3 -4 1.1 4 6 -5 1.12 4 6 -6 2.0 4 6 -7 100.0 7 7 + -- !query 76 select id, f_float8, first(id) over w, last(id) over w from numerics window w as (order by f_float8 range between - 1 preceding and 1.1 following) + 1 preceding and 1 following) -- !query 76 schema -struct +struct -- !query 76 output -1 -3.0 1 1 -2 -1.0 2 3 -3 0.0 2 4 -4 1.1 4 6 -5 1.12 4 6 -6 2.0 4 6 -7 100.0 7 7 + -- !query 77 select id, f_float8, first(id) over w, last(id) over w from numerics window w as (order by f_float8 range between - 'inf' preceding and 'inf' following) + 1 preceding and 1.1 following) -- !query 77 schema -struct +struct -- !query 77 output -1 -3.0 NULL NULL -2 -1.0 NULL NULL -3 0.0 NULL NULL -4 1.1 NULL NULL -5 1.12 NULL NULL -6 2.0 NULL NULL -7 100.0 NULL NULL + -- !query 78 select id, f_float8, first(id) over w, last(id) over w from numerics window w as (order by f_float8 range between - 1.1 preceding and 'NaN' following) + 'inf' preceding and 'inf' following) -- !query 78 schema -struct +struct -- !query 78 output -1 -3.0 1 7 -2 -1.0 2 7 -3 0.0 2 7 -4 1.1 3 7 -5 1.12 4 7 -6 2.0 4 7 -7 100.0 7 7 --- !query 79 --- error, NaN disallowed -select id, f_numeric, first(id) over w, last(id) over w +-- !query 79 +select id, f_float8, first(id) over w, last(id) over w from numerics -window w as (order by f_numeric range between - 1 preceding and 1 following) +window w as (order by f_float8 range between + 1.1 preceding and 'NaN' following) -- !query 79 schema -struct +struct -- !query 79 output -1 -3 1 1 -2 -1 2 3 -3 0 2 5 -4 1 3 6 -5 1 3 6 -6 2 4 6 -7 100 7 7 + -- !query 80 select id, f_numeric, first(id) over w, last(id) over w from numerics window w as (order by f_numeric range between - 1 preceding and 1.1 following) + 1 preceding and 1 following) -- !query 80 schema -struct +struct -- !query 80 output -1 -3 1 1 -2 -1 2 3 -3 0 2 5 -4 1 3 6 -5 1 3 6 -6 2 4 6 -7 100 7 7 + -- !query 81 @@ -1382,38 +1338,32 @@ window w as (order by f_numeric range between -- !query 81 schema struct -- !query 81 output -1 -3 1 1 -2 -1 2 3 -3 0 2 5 -4 1 3 6 -5 1 3 6 -6 2 4 6 -7 100 7 7 --- !query 82 --- currently unsupported +-- !query 82 select id, f_numeric, first(id) over w, last(id) over w from numerics window w as (order by f_numeric range between - 1.1 preceding and 'NaN' following) + 1 preceding and 1.1 following) -- !query 82 schema -struct +struct -- !query 82 output -1 -3 NULL NULL -2 -1 NULL NULL -3 0 NULL NULL -4 1 NULL NULL -5 1 NULL NULL -6 2 NULL NULL -7 100 NULL NULL + -- !query 83 --- error, NaN disallowed +select id, f_numeric, first(id) over w, last(id) over w +from numerics +window w as (order by f_numeric range between + 1.1 preceding and 'NaN' following) +-- !query 83 schema +struct +-- !query 83 output + +-- !query 84 create table datetimes ( id int, f_time timestamp, @@ -1422,13 +1372,13 @@ create table datetimes ( f_timestamptz timestamp, f_timestamp timestamp ) using parquet --- !query 83 schema +-- !query 84 schema struct<> --- !query 83 output +-- !query 84 output --- !query 84 +-- !query 85 insert into datetimes values (1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), (2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), @@ -1440,22 +1390,22 @@ insert into datetimes values (8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), (9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), (10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54') --- !query 84 schema +-- !query 85 schema struct<> --- !query 84 output +-- !query 85 output --- !query 85 +-- !query 86 WITH cte (x) AS ( SELECT * FROM range(1, 36, 2) ) SELECT x, (sum(x) over w) FROM cte WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) --- !query 85 schema +-- !query 86 schema struct --- !query 85 output +-- !query 86 output 1 4 11 33 13 39 @@ -1476,16 +1426,16 @@ struct --- !query 86 output +-- !query 87 output 1 1 11 11 13 13 @@ -1506,7 +1456,7 @@ struct --- !query 87 output +-- !query 88 output 1 2 1 3 1 7 @@ -1545,7 +1495,7 @@ struct --- !query 88 output +-- !query 89 output 1 3 1 3 1 3 @@ -1584,88 +1534,85 @@ struct --- !query 89 output +-- !query 90 output --- !query 90 +-- !query 91 create table t1 (f1 int, f2 int) using parquet --- !query 90 schema +-- !query 91 schema struct<> --- !query 90 output +-- !query 91 output --- !query 91 +-- !query 92 insert into t1 values (1,1),(1,2),(2,2) --- !query 91 schema +-- !query 92 schema struct<> --- !query 91 output +-- !query 92 output --- !query 92 +-- !query 93 select f1, sum(f1) over (partition by f1 range between 1 preceding and 1 following) from t1 where f1 = f2 --- !query 92 schema +-- !query 93 schema struct<> --- !query 92 output +-- !query 93 output org.apache.spark.sql.AnalysisException cannot resolve '(PARTITION BY default.t1.`f1` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)' due to data type mismatch: A range window frame cannot be used in an unordered window specification.; line 1 pos 24 --- !query 93 --- error, must have order by - - +-- !query 94 select f1, sum(f1) over (partition by f1, f1 order by f2 range between 2 preceding and 1 preceding) from t1 where f1 = f2 --- !query 93 schema +-- !query 94 schema struct --- !query 93 output +-- !query 94 output 1 NULL 2 NULL --- !query 94 +-- !query 95 select f1, sum(f1) over (partition by f1, f2 order by f2 range between 1 following and 2 following) from t1 where f1 = f2 --- !query 94 schema +-- !query 95 schema struct --- !query 94 output +-- !query 95 output 1 NULL 2 NULL --- !query 95 +-- !query 96 SELECT rank() OVER (ORDER BY length('abc')) --- !query 95 schema +-- !query 96 schema struct --- !query 95 output +-- !query 96 output 1 --- !query 96 +-- !query 97 SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10 --- !query 96 schema +-- !query 97 schema struct<> --- !query 96 output +-- !query 97 output org.apache.spark.sql.AnalysisException It is not allowed to use window functions inside WHERE and HAVING clauses; --- !query 97 +-- !query 98 SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10 --- !query 97 schema +-- !query 98 schema struct<> --- !query 97 output +-- !query 98 output org.apache.spark.sql.AnalysisException The query operator `Join` contains one or more unsupported @@ -1673,11 +1620,11 @@ expression types Aggregate, Window or Generate. Invalid expressions: [row_number() OVER (ORDER BY default.empsalary.`salary` ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)]; --- !query 98 +-- !query 99 SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1 --- !query 98 schema +-- !query 99 schema struct<> --- !query 98 output +-- !query 99 output org.apache.spark.sql.AnalysisException The query operator `Aggregate` contains one or more unsupported @@ -1685,11 +1632,11 @@ expression types Aggregate, Window or Generate. Invalid expressions: [RANK() OVER (ORDER BY 1 ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)]; --- !query 99 +-- !query 100 SELECT * FROM rank() OVER (ORDER BY random()) --- !query 99 schema +-- !query 100 schema struct<> --- !query 99 output +-- !query 100 output org.apache.spark.sql.catalyst.parser.ParseException no viable alternative at input 'ORDER'(line 1, pos 27) @@ -1699,29 +1646,29 @@ SELECT * FROM rank() OVER (ORDER BY random()) ---------------------------^^^ --- !query 100 +-- !query 101 SELECT * FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10 --- !query 100 schema +-- !query 101 schema struct<> --- !query 100 output +-- !query 101 output org.apache.spark.sql.AnalysisException It is not allowed to use window functions inside WHERE and HAVING clauses; --- !query 101 +-- !query 102 SELECT * FROM empsalary WHERE rank() OVER (ORDER BY random()) --- !query 101 schema +-- !query 102 schema struct<> --- !query 101 output +-- !query 102 output org.apache.spark.sql.AnalysisException It is not allowed to use window functions inside WHERE and HAVING clauses; --- !query 102 +-- !query 103 select rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1 --- !query 102 schema +-- !query 103 schema struct<> --- !query 102 output +-- !query 103 output org.apache.spark.sql.catalyst.parser.ParseException no viable alternative at input 'ORDER'(line 1, pos 39) @@ -1731,42 +1678,30 @@ select rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1 ---------------------------------------^^^ --- !query 103 -SELECT range(1, 100) OVER () FROM empsalary --- !query 103 schema -struct<> --- !query 103 output -org.apache.spark.sql.AnalysisException -Undefined function: 'range'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 7 - - -- !query 104 -SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 +SELECT range(1, 100) OVER () FROM empsalary -- !query 104 schema struct<> -- !query 104 output org.apache.spark.sql.AnalysisException -cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; line 1 pos 7 +Undefined function: 'range'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 7 -- !query 105 -DROP TABLE empsalary +SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 -- !query 105 schema struct<> -- !query 105 output - +org.apache.spark.sql.AnalysisException +cannot resolve 'ntile(0)' due to data type mismatch: Buckets expression must be positive, but got: 0; line 1 pos 7 -- !query 106 -SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +DROP TABLE empsalary -- !query 106 schema -struct +struct<> -- !query 106 output -1 1.5 -2 2.0 -3 NULL -4 NULL + -- !query 107 @@ -1795,24 +1730,24 @@ struct +struct -- !query 109 output -1 2 -2 2.5 +1 1.5 +2 2.0 3 NULL 4 NULL -- !query 110 -SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) -- !query 110 schema -struct +struct -- !query 110 output -1 3 -2 2 +1 2 +2 2.5 3 NULL 4 NULL @@ -1843,64 +1778,63 @@ struct +struct -- !query 113 output +1 3 +2 2 +3 NULL +4 NULL + + +-- !query 114 +SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) +-- !query 114 schema +struct +-- !query 114 output 1 3.3 2 2.2 3 NULL 4 NULL --- !query 114 +-- !query 115 SELECT SUM(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) --- !query 114 schema +-- !query 115 schema struct --- !query 114 output +-- !query 115 output 3 5 6.01 --- !query 115 +-- !query 116 SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 115 schema +-- !query 116 schema struct --- !query 115 output +-- !query 116 output 1 2 2 1 3 0 4 0 --- !query 116 +-- !query 117 SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 116 schema +-- !query 117 schema struct --- !query 116 output +-- !query 117 output 1 4 2 3 3 2 4 1 --- !query 117 -SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) --- !query 117 schema -struct --- !query 117 output -0.0 -11266.666666666666 -13868.750000000002 -21703.999999999996 -4225.0 - - -- !query 118 SELECT VAR_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) @@ -1941,16 +1875,16 @@ struct +struct -- !query 121 output -16900.0 -18491.666666666668 -27129.999999999996 -8450.0 -NaN +0.0 +11266.666666666666 +13868.750000000002 +21703.999999999996 +4225.0 -- !query 122 @@ -1993,7 +1927,7 @@ NaN -- !query 125 -SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +SELECT VAR_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 125 schema struct @@ -2045,17 +1979,16 @@ NaN -- !query 129 -SELECT STDDEV_POP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +SELECT VARIANCE(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) -- !query 129 schema -struct +struct -- !query 129 output -0.0 -106.14455552060438 -117.76565713313879 -147.32277488562315 -147.32277488562315 -65.0 +16900.0 +18491.666666666668 +27129.999999999996 +8450.0 +NaN -- !query 130 @@ -2101,17 +2034,17 @@ struct +struct -- !query 133 output -130.0 -135.9840676942217 -164.7118696390761 -164.7118696390761 -91.92388155425118 -NaN +0.0 +106.14455552060438 +117.76565713313879 +147.32277488562315 +147.32277488562315 +65.0 -- !query 134 @@ -2157,8 +2090,8 @@ NaN -- !query 137 -SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) - FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +SELECT STDDEV_SAMP(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) -- !query 137 schema struct -- !query 137 output @@ -2213,68 +2146,102 @@ NaN -- !query 141 +SELECT STDDEV(n) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- !query 141 schema +struct +-- !query 141 output +130.0 +135.9840676942217 +164.7118696390761 +164.7118696390761 +91.92388155425118 +NaN + + +-- !query 142 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 141 schema +-- !query 142 schema struct --- !query 141 output +-- !query 142 output 1 1 2 2 3 NULL 4 NULL --- !query 142 +-- !query 143 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) --- !query 142 schema +-- !query 143 schema struct --- !query 142 output +-- !query 143 output 1 3 2 2 3 NULL 4 NULL --- !query 143 +-- !query 144 SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) --- !query 143 schema +-- !query 144 schema struct --- !query 143 output +-- !query 144 output 1 3 2 6 3 9 4 7 --- !query 144 +-- !query 145 +SELECT a, b, + SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +FROM (VALUES(1,1),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b) +-- !query 145 schema +struct<> +-- !query 145 output +org.apache.spark.sql.AnalysisException +incompatible types found in column col2 for inline table; line 3 pos 6 + + +-- !query 146 +select f_float4, sum(f_float4) over (order by f_float8 rows between 1 + preceding and current row) from numerics +-- !query 146 schema +struct +-- !query 146 output + + + +-- !query 147 drop table numerics --- !query 144 schema +-- !query 147 schema struct<> --- !query 144 output +-- !query 147 output --- !query 145 +-- !query 148 drop table t1 --- !query 145 schema +-- !query 148 schema struct<> --- !query 145 output +-- !query 148 output --- !query 146 +-- !query 149 drop view int4_tbl --- !query 146 schema +-- !query 149 schema struct<> --- !query 146 output +-- !query 149 output --- !query 147 +-- !query 150 drop table datetimes --- !query 147 schema +-- !query 150 schema struct<> --- !query 147 output +-- !query 150 output From 80f29158d67574b6a69924a2d606ebc2fd94ada8 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sat, 7 Sep 2019 12:03:52 -0300 Subject: [PATCH 25/25] adds comment for some queries Signed-off-by: DylanGuedes --- .../sql-tests/inputs/pgSQL/window.sql | 29 +++++++++++++++---- .../sql-tests/results/pgSQL/window.sql.out | 21 ++++---------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql index 9c1a382cc807c..055fd7476ae30 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql @@ -1,7 +1,7 @@ -- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group -- -- Window Functions Testing --- https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/sql/window.sql +-- https://github.com/postgres/postgres/blob/REL_12_BETA3/src/test/regress/sql/window.sql CREATE TEMPORARY VIEW tenk2 AS SELECT * FROM tenk1; @@ -1038,13 +1038,16 @@ SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1; -- cleanup DROP TABLE empsalary; +-- Spark doesn't handle UDFs in SQL -- test user-defined window function with named args and default args -- CREATE FUNCTION nth_value_def(val anyelement, n integer = 1) RETURNS anyelement -- LANGUAGE internal WINDOW IMMUTABLE STRICT AS 'window_nth_value'; +-- Spark doesn't handle UDFs in SQL -- SELECT nth_value_def(n := 2, val := ten) OVER (PARTITION BY four), ten, four -- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s; +-- Spark doesn't handle UDFs in SQL -- SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four -- FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s; @@ -1055,18 +1058,22 @@ DROP TABLE empsalary; -- create aggregates that record the series of transform calls (these are -- intentionally not true inverses) +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS -- $$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$ -- LANGUAGE SQL IMMUTABLE; +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS -- $$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$ -- LANGUAGE SQL IMMUTABLE; +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS -- $$ SELECT $1 || '-' || quote_nullable($2) $$ -- LANGUAGE SQL IMMUTABLE; +-- Spark doesn't handle UDFs in SQL -- CREATE AGGREGATE logging_agg_nonstrict (anyelement) -- ( -- stype = text, @@ -1076,6 +1083,7 @@ DROP TABLE empsalary; -- minvfunc = logging_minvfunc_nonstrict -- ); +-- Spark doesn't handle UDFs in SQL -- CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement) -- ( -- stype = text, @@ -1087,18 +1095,22 @@ DROP TABLE empsalary; -- minitcond = 'MI' -- ); +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS -- $$ SELECT $1 || '*' || quote_nullable($2) $$ -- LANGUAGE SQL STRICT IMMUTABLE; +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS -- $$ SELECT $1 || '+' || quote_nullable($2) $$ -- LANGUAGE SQL STRICT IMMUTABLE; +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS -- $$ SELECT $1 || '-' || quote_nullable($2) $$ -- LANGUAGE SQL STRICT IMMUTABLE; +-- Spark doesn't handle UDFs in SQL -- CREATE AGGREGATE logging_agg_strict (text) -- ( -- stype = text, @@ -1108,6 +1120,7 @@ DROP TABLE empsalary; -- minvfunc = logging_minvfunc_strict -- ); +-- Spark doesn't handle UDFs in SQL -- CREATE AGGREGATE logging_agg_strict_initcond (anyelement) -- ( -- stype = text, @@ -1119,6 +1132,7 @@ DROP TABLE empsalary; -- minitcond = 'MI' -- ); +-- Spark doesn't handle UDFs in SQL -- test strict and non-strict cases -- SELECT -- p::text || ',' || i::text || ':' || COALESCE(v::text, 'NULL') AS row, @@ -1140,6 +1154,7 @@ DROP TABLE empsalary; -- WINDOW wnd AS (PARTITION BY P ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) -- ORDER BY p, i; +-- Spark doesn't handle UDFs in SQL -- and again, but with filter -- SELECT -- p::text || ',' || i::text || ':' || @@ -1162,6 +1177,7 @@ DROP TABLE empsalary; -- WINDOW wnd AS (PARTITION BY p ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) -- ORDER BY p, i; +-- Spark doesn't handle UDFs in SQL -- test that volatile arguments disable moving-aggregate mode -- SELECT -- i::text || ':' || COALESCE(v::text, 'NULL') as row, @@ -1177,6 +1193,7 @@ DROP TABLE empsalary; -- WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) -- ORDER BY i; +-- Spark doesn't handle UDFs in SQL -- SELECT -- i::text || ':' || COALESCE(v::text, 'NULL') as row, -- logging_agg_strict(v::text) filter(where true) @@ -1191,6 +1208,7 @@ DROP TABLE empsalary; -- WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) -- ORDER BY i; +-- Spark doesn't handle UDFs in SQL -- test that non-overlapping windows don't use inverse transitions -- SELECT -- logging_agg_strict(v::text) OVER wnd @@ -1202,15 +1220,18 @@ DROP TABLE empsalary; -- WINDOW wnd AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) -- ORDER BY i; +-- Spark doesn't handle UDFs in SQL -- test that returning NULL from the inverse transition functions -- restarts the aggregation from scratch. The second aggregate is supposed -- to test cases where only some aggregates restart, the third one checks -- that one aggregate restarting doesn't cause others to restart. +-- Spark doesn't handle UDFs in SQL -- CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS -- $$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$ -- LANGUAGE SQL STRICT; +-- Spark doesn't handle UDFs in SQL -- CREATE AGGREGATE sum_int_randomrestart (int4) -- ( -- stype = int4, @@ -1220,6 +1241,7 @@ DROP TABLE empsalary; -- minvfunc = sum_int_randrestart_minvfunc -- ); +-- Spark doesn't handle UDFs in SQL -- WITH -- vs AS ( -- SELECT i, (random() * 100)::int4 AS v @@ -1258,7 +1280,7 @@ SELECT i,AVG(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWIN FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v); -- [SPARK-28602] Spark does not recognize 'interval' type as 'numeric' --- SELECT i,AVG(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +-- SELECT i,AVG(v::interval) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) -- FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v); SELECT i,SUM(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) @@ -1379,9 +1401,6 @@ SELECT a, b, SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM (VALUES(1,1),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b); -select f_float4, sum(f_float4) over (order by f_float8 rows between 1 - preceding and current row) from numerics; - -- It might be tempting for someone to add an inverse trans function for -- float and double precision. This should not be done as it can give incorrect -- results. This test should fail if anyone ever does this without thinking too diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out index 9f9a1e162204e..ef71454395af0 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/window.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 151 +-- Number of queries: 150 -- !query 0 @@ -2207,16 +2207,15 @@ incompatible types found in column col2 for inline table; line 3 pos 6 -- !query 146 -select f_float4, sum(f_float4) over (order by f_float8 rows between 1 - preceding and current row) from numerics +drop table numerics -- !query 146 schema -struct +struct<> -- !query 146 output -- !query 147 -drop table numerics +drop table t1 -- !query 147 schema struct<> -- !query 147 output @@ -2224,7 +2223,7 @@ struct<> -- !query 148 -drop table t1 +drop view int4_tbl -- !query 148 schema struct<> -- !query 148 output @@ -2232,16 +2231,8 @@ struct<> -- !query 149 -drop view int4_tbl +drop table datetimes -- !query 149 schema struct<> -- !query 149 output - - --- !query 150 -drop table datetimes --- !query 150 schema -struct<> --- !query 150 output -