提交 683414f1 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add some comments

上级 fcd9ac4c
......@@ -521,7 +521,7 @@ public final class WindowFrame {
int startIndex, int endIndex, boolean reverse) {
if (exclusion == WindowFrameExclusion.EXCLUDE_CURRENT_ROW) {
if (currentRow < startIndex || currentRow > endIndex) {
// Nothing to do
// Nothing to exclude
} else if (currentRow == startIndex) {
startIndex++;
} else if (currentRow == endIndex) {
......@@ -530,10 +530,13 @@ public final class WindowFrame {
return biIterator(orderedRows, startIndex, currentRow - 1, currentRow + 1, endIndex, reverse);
}
} else {
// Do not include previous rows if they are not in the range
int exStart = toGroupStart(orderedRows, sortOrder, currentRow, startIndex);
// Do not include next rows if they are not in the range
int exEnd = toGroupEnd(orderedRows, sortOrder, currentRow, endIndex);
boolean includeCurrentRow = exclusion == WindowFrameExclusion.EXCLUDE_TIES;
if (includeCurrentRow) {
// Simplify exclusion if possible
if (currentRow == exStart) {
exStart++;
includeCurrentRow = false;
......@@ -543,7 +546,7 @@ public final class WindowFrame {
}
}
if (exStart > exEnd || exEnd < startIndex || exStart > endIndex) {
// Nothing to do
// Empty range or nothing to exclude
} else if (includeCurrentRow) {
if (startIndex == exStart) {
if (endIndex == exEnd) {
......
......@@ -351,10 +351,10 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOW
> rows: 4
SELECT *,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING) N,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE TIES) T,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 1 PRECEDING AND 0 FOLLOWING EXCLUDE TIES) T1
FROM TEST;
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING) N,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE TIES) T,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 1 PRECEDING AND 0 FOLLOWING EXCLUDE TIES) T1
FROM TEST;
> ID VALUE N T T1
> -- ----- --------- --- ------------
> 1 1 (1, 2) (1) (1)
......@@ -418,7 +418,7 @@ SELECT ID, VALUE,
> rows: 8
SELECT ID, VALUE, ARRAY_AGG(ID) OVER(ORDER BY VALUE ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING EXCLUDE GROUP) G
FROM TEST ORDER BY ID FETCH FIRST 3 ROWS ONLY;
FROM TEST ORDER BY ID FETCH FIRST 3 ROWS ONLY;
> ID VALUE G
> -- ----- ------
> 1 1 (3)
......@@ -427,7 +427,7 @@ SELECT ID, VALUE, ARRAY_AGG(ID) OVER(ORDER BY VALUE ROWS BETWEEN 1 FOLLOWING AND
> rows (ordered): 3
SELECT ID, VALUE, ARRAY_AGG(ID) OVER(ORDER BY VALUE ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE GROUP) G
FROM TEST ORDER BY ID FETCH FIRST 3 ROWS ONLY;
FROM TEST ORDER BY ID FETCH FIRST 3 ROWS ONLY;
> ID VALUE G
> -- ----- ------
> 1 1 null
......
......@@ -797,6 +797,6 @@ xym normalizes coord setz xyzm geometrycollection multipolygon mixup rings polyg
pointzm pointz pointm dimensionality redefine forum measures
mpg casted pzm mls constrained subtypes complains
ranks rno dro rko precede cume reopens preceding unbounded rightly itr lag maximal tiles tile ntile signify
partitioned
partitioned tri
discard enhancements nolock
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论