Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
temporarily turns off ansi
Signed-off-by: DylanGuedes <[email protected]>
  • Loading branch information
DylanGuedes committed Aug 14, 2019
commit bea5ba6e577a47f4c57b845de8b54507142e2f0b
22 changes: 12 additions & 10 deletions sql/core/src/test/resources/sql-tests/inputs/pgSQL/window.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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()));
Copy link
Member

@dongjoon-hyun dongjoon-hyun Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ur, please file another JIRA issue since the behavior is different.

postgres=# SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random()));
ERROR:  window functions are not allowed in window definitions
LINE 1: SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())...
spark-sql> SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random()));
1


-- some other errors
select * from
Expand Down Expand Up @@ -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;
Loading