Registering pre-existing tables
int4_tbl
INT4_TBL
tenk1
tenk2
--
-- WINDOW FUNCTIONS
--
CREATE TEMPORARY TABLE empsalary (
depname varchar,
empno bigint,
salary int,
enroll_date date
);
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;
-- 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;
SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname);
SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w;
-stdin-:: Error: Parse Sql
-stdin-::1:121: Error: Over is not allowed in: ORDER BY
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;
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Unsupported function: percent_rank
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Unsupported function: cume_dist
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Unsupported function: ntile
SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10;
^
SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2;
^
-stdin-::1:8: Error: Unsupported function: ntile
SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2;
^
SELECT lag(ten) 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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Expected one argument in functionlag
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Expected one argument in functionlag
SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
SELECT lag(ten, four, 0.7) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT lag(ten, four, 0.7) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT lag(ten, four, 0.7) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
^
-stdin-::1:8: Error: Expected one argument in functionlag
SELECT lag(ten, four, 0.7) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
^
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Expected one argument in functionlead
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
-stdin-::1:8: Error: Expected one argument in functionlead
SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
^
SELECT lead(ten * 2, 1, -1.4) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT lead(ten * 2, 1, -1.4) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT lead(ten * 2, 1, -1.4) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
^
-stdin-::1:8: Error: Expected one argument in functionlead
SELECT lead(ten * 2, 1, -1.4) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten;
^
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;
SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four
FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four
^
-stdin-::1:8: Error: At function: PgWindowCall
SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four
^
-stdin-::1:8: Error: Unsupported function: nth_value
SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four
^
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;
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;
-- 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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
-- more than one window with GROUP BY
^
-stdin-::1:1: Error: Duplicated member: sum
-- more than one window with GROUP BY
^
-- 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
SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten)
FROM tenk1 s WHERE unique2 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
-- subplan
^
-stdin-::2:8: Error: At function: PgWindowCall
SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten)
^
-stdin-::2:8: Error: Expected one argument in functionlead
SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten)
^
-- 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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem
-- strict aggs
^
-stdin-::4:13: Error: Star is incompatible to column reference
CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus,
^
-stdin-::4:70: Error: Star is incompatible to column reference
CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus,
^
-- 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;
-- window and aggregate with GROUP BY expression (9.2 bug)
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: RawStmt: alternative is not implemented yet : 276
-- window and aggregate with GROUP BY expression (9.2 bug)
^
-- 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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT four, ten,
^
-stdin-::2:16: Error: At function: PgWindow
sum(ten) over (partition by four order by ten range between unbounded preceding and current row),
^
-stdin-::2:16: Error: Unsupported frame type: range
sum(ten) over (partition by four order by ten range between unbounded preceding and current row),
^
-stdin-::3:23: Error: At function: PgWindow
last_value(ten) over (partition by four order by ten range between unbounded preceding and current row)
^
-stdin-::3:23: Error: Unsupported frame type: range
last_value(ten) over (partition by four order by ten range between unbounded preceding and current row)
^
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT four, ten,
^
-stdin-::2:16: Error: At function: PgWindow
sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following),
^
-stdin-::2:16: Error: Unsupported frame type: range
sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following),
^
-stdin-::3:23: Error: At function: PgWindow
last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following)
^
-stdin-::3:23: Error: Unsupported frame type: range
last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following)
^
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT four, ten/4 as two,
^
-stdin-::2:18: Error: At function: PgWindow
sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row),
^
-stdin-::2:18: Error: Unsupported frame type: range
sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row),
^
-stdin-::3:25: Error: At function: PgWindow
last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row)
^
-stdin-::3:25: Error: Unsupported frame type: range
last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row)
^
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (order by four range between current row and unbounded following),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (order by four range between current row and unbounded following),
^
-stdin-::1:26: Error: Unsupported frame type: range
SELECT sum(unique1) over (order by four range between current row and unbounded following),
^
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;
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row),
^
-stdin-::1:26: Error: Excludes are not supported
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 group),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group),
^
-stdin-::1:26: Error: Excludes are not supported
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group),
^
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties),
^
-stdin-::1:26: Error: Excludes are not supported
SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties),
^
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row),
^
-stdin-::1:34: Error: At function: PgWindow
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row),
^
-stdin-::1:34: Error: Excludes are not supported
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row),
^
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
^
-stdin-::1:34: Error: At function: PgWindow
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
^
-stdin-::1:34: Error: Excludes are not supported
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
^
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
^
-stdin-::1:34: Error: At function: PgWindow
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
^
-stdin-::1:34: Error: Excludes are not supported
SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
^
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;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row),
^
-stdin-::1:33: Error: At function: PgWindow
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row),
^
-stdin-::1:33: Error: Excludes are not supported
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row),
^
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
^
-stdin-::1:33: Error: At function: PgWindow
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
^
-stdin-::1:33: Error: Excludes are not supported
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group),
^
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
^
-stdin-::1:33: Error: At function: PgWindow
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
^
-stdin-::1:33: Error: Excludes are not supported
SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties),
^
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;
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);
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (w range between current row and unbounded following),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (w range between current row and unbounded following),
^
-stdin-::1:26: Error: Window reference is not supported
SELECT sum(unique1) over (w range between current row and unbounded following),
^
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);
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row),
^
-stdin-::1:26: Error: Window reference is not supported
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row),
^
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);
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group),
^
-stdin-::1:26: Error: Window reference is not supported
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group),
^
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);
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties),
^
-stdin-::1:26: Error: At function: PgWindow
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties),
^
-stdin-::1:26: Error: Window reference is not supported
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties),
^
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);
-stdin-:: Error: Type annotation
-stdin-::1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
SELECT first_value(unique1) over w,
^
-stdin-::5:13: Error: At function: PgWindow
WINDOW w AS (order by four range between current row and unbounded following);
^
-stdin-::5:13: Error: Unsupported frame type: range
WINDOW w AS (order by four range between current row and unbounded following);
^
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;
-stdin-:: Error: Parse Sql
-stdin-::3:8: Error: SubLinks are not allowed in: FRAME
rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING),
^
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE TEMP VIEW v_window AS
^
SELECT * FROM v_window;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.v_window
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE OR REPLACE TEMP VIEW v_window AS
^
SELECT * FROM v_window;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.v_window
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE OR REPLACE TEMP VIEW v_window AS
^
SELECT * FROM v_window;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.v_window
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE OR REPLACE TEMP VIEW v_window AS
^
SELECT * FROM v_window;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.v_window
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE OR REPLACE TEMP VIEW v_window AS
^
SELECT * FROM v_window;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.v_window
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE OR REPLACE TEMP VIEW v_window AS
^
SELECT * FROM v_window;
-stdin-:: Fatal: Table metadata loading
-stdin-:: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.v_window
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
SELECT pg_get_viewdef('v_window');
^
DROP VIEW v_window;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: View not found: '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;
-stdin-:: Error: Parse Sql
-stdin-::1:1: Error: expected at least one target column
CREATE TEMP VIEW v_window AS
^
SELECT pg_get_viewdef('v_window');
-stdin-:: Fatal: Execution
-stdin-::1:1: Fatal: Execution of node: Result
SELECT pg_get_viewdef('v_window');
^
-stdin-::1:1: Fatal: ERROR: relation "v_window" does not exist
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;
-stdin-:: Error: Expression evaluation
-stdin-::2:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding),
^
-stdin-:: Error: Type annotation
-stdin-::2:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding),
^
-stdin-::2:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding),
^
SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding),
unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding),
^
-stdin-::1:63: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others),
^
-stdin-::1:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row),
^
-stdin-::1:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group),
^
-stdin-::1:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties),
^
-stdin-::1:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties),
^
-stdin-::1:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group),
^
-stdin-::1:58: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following),
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following),
^
-stdin-::1:79: Error: Can't unwrap PostgreSQL type
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::int8 preceding and 6::int2 following
exclude current row),unique1, four
FROM tenk1 WHERE unique1 < 10;
-stdin-:: Error: Expression evaluation
-stdin-::1:26: Error: At function: EvaluateExpr
SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following
^
-stdin-:: Error: Type annotation
-stdin-::1:26: Error: At function: Unwrap
SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following
^
-stdin-::1:79: Error: Can't unwrap PostgreSQL type
SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following
^
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following),
salary, enroll_date from empsalary;
-stdin-:: Error: Expression evaluation
-stdin-::1:25: Error: At function: EvaluateExpr
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following),
^
-stdin-:: Error: Type annotation
-stdin-::1:25: Error: At function: Unwrap
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following),
^
-stdin-::1:71: Error: Can't unwrap PostgreSQL type
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:25: Error: At function: EvaluateExpr
select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following),
^
-stdin-:: Error: Type annotation
-stdin-::1:25: Error: At function: Unwrap
select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following),
^
-stdin-::1:76: Error: Can't unwrap PostgreSQL type
select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-::1:25: Error: At function: EvaluateExpr
select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following),
^
-stdin-:: Error: Type annotation
-stdin-::1:25: Error: At function: Unwrap
select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following),
^
-stdin-::1:76: Error: Can't unwrap PostgreSQL type
select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following),
^
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;
-stdin-:: Error: Expression evaluation
-stdin-: