提交 4e96e4d0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Move QUALIFY clause after WINDOW clause

上级 cb8d0ff9
...@@ -11,8 +11,8 @@ selectExpression [,...] ...@@ -11,8 +11,8 @@ selectExpression [,...]
[ FROM tableExpression [,...] ] [ FROM tableExpression [,...] ]
[ WHERE expression ] [ WHERE expression ]
[ GROUP BY expression [,...] ] [ HAVING expression ] [ GROUP BY expression [,...] ] [ HAVING expression ]
[ QUALIFY expression ]
[ WINDOW { { windowName AS windowSpecification } [,...] } ] [ WINDOW { { windowName AS windowSpecification } [,...] } ]
[ QUALIFY expression ]
[ { UNION [ ALL ] | EXCEPT | MINUS | INTERSECT } select ] [ { UNION [ ALL ] | EXCEPT | MINUS | INTERSECT } select ]
[ ORDER BY order [,...] ] [ ORDER BY order [,...] ]
[ LIMIT expression [ OFFSET expression ] [ SAMPLE_SIZE rowCountInt ] ] [ LIMIT expression [ OFFSET expression ] [ SAMPLE_SIZE rowCountInt ] ]
......
...@@ -2750,11 +2750,6 @@ public class Parser { ...@@ -2750,11 +2750,6 @@ public class Parser {
Expression condition = readExpression(); Expression condition = readExpression();
command.setHaving(condition); command.setHaving(condition);
} }
if (readIf(QUALIFY)) {
command.setWindowQuery();
Expression condition = readExpression();
command.setQualify(condition);
}
if (readIf(WINDOW)) { if (readIf(WINDOW)) {
do { do {
int index = parseIndex; int index = parseIndex;
...@@ -2766,6 +2761,11 @@ public class Parser { ...@@ -2766,6 +2761,11 @@ public class Parser {
} }
} while (readIf(COMMA)); } while (readIf(COMMA));
} }
if (readIf(QUALIFY)) {
command.setWindowQuery();
Expression condition = readExpression();
command.setQualify(condition);
}
command.setParameterList(parameters); command.setParameterList(parameters);
currentSelect = oldSelect; currentSelect = oldSelect;
currentPrepared = oldPrepared; currentPrepared = oldPrepared;
......
...@@ -84,12 +84,12 @@ SELECT *, ...@@ -84,12 +84,12 @@ SELECT *,
> rows: 9 > rows: 9
SELECT *, SELECT *,
ROW_NUMBER() OVER (PARTITION BY CATEGORY ORDER BY ID) RN, ROW_NUMBER() OVER W RN,
RANK() OVER (PARTITION BY CATEGORY ORDER BY ID) RK, RANK() OVER W RK,
DENSE_RANK() OVER (PARTITION BY CATEGORY ORDER BY ID) DR, DENSE_RANK() OVER W DR,
ROUND(PERCENT_RANK() OVER (PARTITION BY CATEGORY ORDER BY ID), 2) PR, ROUND(PERCENT_RANK() OVER W, 2) PR,
ROUND(CUME_DIST() OVER (PARTITION BY CATEGORY ORDER BY ID), 2) CD ROUND(CUME_DIST() OVER W, 2) CD
FROM TEST QUALIFY ROW_NUMBER() OVER (PARTITION BY CATEGORY ORDER BY ID) = 2; FROM TEST WINDOW W AS (PARTITION BY CATEGORY ORDER BY ID) QUALIFY ROW_NUMBER() OVER W = 2;
> ID CATEGORY VALUE RN RK DR PR CD > ID CATEGORY VALUE RN RK DR PR CD
> -- -------- ----- -- -- -- --- ---- > -- -------- ----- -- -- -- --- ----
> 2 1 12 2 2 2 0.5 0.67 > 2 1 12 2 2 2 0.5 0.67
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论