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

Move QUALIFY clause after WINDOW clause

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