Unverified 提交 f5c5d3a1 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1754 from katzyn/window

Fix window functions in JOIN with ON condition
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>PR #1754: Fix window functions in JOIN with ON condition
</li>
<li>Issue #1751: making it easier to open console and create local databases <li>Issue #1751: making it easier to open console and create local databases
</li> </li>
<li>Issue #1750: JOIN t ON t.col IN (SELECT ...) throws AssertionError <li>Issue #1750: JOIN t ON t.col IN (SELECT ...) throws AssertionError
......
...@@ -1705,6 +1705,14 @@ public class Select extends Query { ...@@ -1705,6 +1705,14 @@ public class Select extends Query {
} }
comp = comp.optimize(session); comp = comp.optimize(session);
boolean addToCondition = true; boolean addToCondition = true;
if (isWindowQuery) {
if (qualify == null) {
qualify = comp;
} else {
qualify = new ConditionAndOr(ConditionAndOr.AND, comp, qualify);
}
return;
}
if (isGroupQuery) { if (isGroupQuery) {
addToCondition = false; addToCondition = false;
for (int i = 0; groupIndex != null && i < groupIndex.length; i++) { for (int i = 0; groupIndex != null && i < groupIndex.length; i++) {
......
...@@ -665,3 +665,19 @@ SELECT X.ID FROM TEST X JOIN TEST Y ON Y.ID IN (SELECT 1); ...@@ -665,3 +665,19 @@ SELECT X.ID FROM TEST X JOIN TEST Y ON Y.ID IN (SELECT 1);
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
CREATE TABLE TEST(A INT, B INT) AS VALUES (1, 10), (2, 20), (4, 40);
> ok
SELECT T1.A, T2.ARR FROM TEST T1 JOIN (
SELECT A, ARRAY_AGG(B) OVER (ORDER BY B ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) ARR FROM TEST
) T2 ON T1.A = T2.A;
> A ARR
> - --------
> 1 [20, 40]
> 2 [40]
> 4 null
> rows: 3
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论