Skip to content

Commit

Permalink
remove 'order by' from the order 19 in the udf-window.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
younggyu chun committed Jul 22, 2019
1 parent 195bcbd commit d376e95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Expand Up @@ -94,7 +94,7 @@ ORDER BY cate, val;
SELECT udf(val), cate, avg(null) OVER(PARTITION BY cate ORDER BY val) FROM testData ORDER BY cate, val;

-- OrderBy not specified
SELECT udf(val), cate, row_number() OVER(PARTITION BY cate ORDER BY val) FROM testData ORDER BY cate, udf(val);
SELECT udf(val), cate, row_number() OVER(PARTITION BY cate) FROM testData ORDER BY cate, udf(val);

-- Over clause is empty
SELECT udf(val), cate, sum(val) OVER(), avg(val) OVER() FROM testData ORDER BY cate, val;
Expand Down
Expand Up @@ -323,19 +323,12 @@ NULL a NULL


-- !query 19
SELECT udf(val), cate, row_number() OVER(PARTITION BY cate ORDER BY val) FROM testData ORDER BY cate, udf(val)
SELECT udf(val), cate, row_number() OVER(PARTITION BY cate) FROM testData ORDER BY cate, udf(val)
-- !query 19 schema
struct<CAST(udf(cast(val as string)) AS INT):int,cate:string,row_number() OVER (PARTITION BY cate ORDER BY val ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):int>
struct<>
-- !query 19 output
NULL NULL 1
3 NULL 2
NULL a 1
1 a 2
1 a 3
2 a 4
1 b 1
2 b 2
3 b 3
org.apache.spark.sql.AnalysisException
Window function row_number() requires window to be ordered, please add ORDER BY clause. For example SELECT row_number()(value_expr) OVER (PARTITION BY window_partition ORDER BY window_ordering) from table;


-- !query 20
Expand Down

0 comments on commit d376e95

Please sign in to comment.