Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8008,11 +8008,6 @@
"count(<targetString>.*) is not allowed. Please use count(*) or expand the columns manually, e.g. count(col1, col2)."
]
},
"_LEGACY_ERROR_TEMP_1030" : {
"message" : [
"Window aggregate function with filter predicate is not supported yet."
]
},
"_LEGACY_ERROR_TEMP_1031" : {
"message" : [
"It is not allowed to use a window function inside an aggregate function. Please use the inner window function in a sub-query."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,6 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
messageParameters = Map("expression" -> expression))
}

def windowAggregateFunctionWithFilterNotSupportedError(): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1030",
messageParameters = Map.empty)
}

def windowFunctionInsideAggregateFunctionNotAllowedError(): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1031",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,17 +688,17 @@ Project [cate#x, sum(val) OVER (PARTITION BY cate ORDER BY val ASC NULLS FIRST R

-- !query
SELECT val, cate,
first_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long
first_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS first_a,
last_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long
last_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS last_a
FROM testData ORDER BY val_long, cate
FROM testData ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
-- !query analysis
Project [val#x, cate#x, first_a#x, last_a#x]
+- Sort [val_long#xL ASC NULLS FIRST, cate#x ASC NULLS FIRST], true
+- Sort [val_long#xL ASC NULLS LAST, val#x ASC NULLS LAST, cate#x ASC NULLS LAST], true
+- Project [val#x, cate#x, first_a#x, last_a#x, val_long#xL]
+- Project [val#x, cate#x, _w0#x, val_long#xL, first_a#x, last_a#x, first_a#x, last_a#x]
+- Window [first_value(val#x, false) FILTER (WHERE _w0#x) windowspecdefinition(val_long#xL ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS first_a#x, last_value(val#x, false) FILTER (WHERE _w0#x) windowspecdefinition(val_long#xL ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS last_a#x], [val_long#xL ASC NULLS FIRST]
+- Window [first_value(val#x, false) FILTER (WHERE _w0#x) windowspecdefinition(val_long#xL ASC NULLS LAST, val#x ASC NULLS LAST, cate#x ASC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS first_a#x, last_value(val#x, false) FILTER (WHERE _w0#x) windowspecdefinition(val_long#xL ASC NULLS LAST, val#x ASC NULLS LAST, cate#x ASC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS last_a#x], [val_long#xL ASC NULLS LAST, val#x ASC NULLS LAST, cate#x ASC NULLS LAST]
+- Project [val#x, cate#x, (cate#x = a) AS _w0#x, val_long#xL]
+- SubqueryAlias testdata
+- View (`testData`, [val#x, val_long#xL, val_double#x, val_date#x, val_timestamp#x, cate#x])
Expand Down
6 changes: 3 additions & 3 deletions sql/core/src/test/resources/sql-tests/inputs/window.sql
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ WINDOW w AS (PARTITION BY cate ORDER BY val);

-- window aggregate with filter predicate: first_value/last_value (imperative aggregate)
SELECT val, cate,
first_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long
first_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS first_a,
last_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long
last_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS last_a
FROM testData ORDER BY val_long, cate;
FROM testData ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST;

-- window aggregate with filter predicate: multiple aggregates with different filters
SELECT val, cate,
Expand Down
12 changes: 6 additions & 6 deletions sql/core/src/test/resources/sql-tests/results/window.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -669,23 +669,23 @@ b 6

-- !query
SELECT val, cate,
first_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long
first_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS first_a,
last_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long
last_value(val) FILTER (WHERE cate = 'a') OVER(ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS last_a
FROM testData ORDER BY val_long, cate
FROM testData ORDER BY val_long NULLS LAST, val NULLS LAST, cate NULLS LAST
-- !query schema
struct<val:int,cate:string,first_a:int,last_a:int>
-- !query output
NULL NULL 1 NULL
1 b 1 NULL
1 a 1 1
3 NULL 1 1
NULL a 1 NULL
1 a 1 1
1 a 1 1
2 b 1 1
2 a 1 2
3 b 1 2
1 b 1 2
NULL NULL 1 2


-- !query
Expand Down