Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void checkLegalityBeforeTypeCoercion() {
if (children().size() >= 2) {
checkValidParams(getOffset(), true);
if (getOffset() instanceof Literal) {
if (((Literal) getOffset()).getDouble() <= 0) {
if (((Literal) getOffset()).getDouble() < 0) {
throw new AnalysisException(
"The offset parameter of LAG must be a constant positive integer: " + this.toSql());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void checkLegalityBeforeTypeCoercion() {
if (children().size() >= 2) {
checkValidParams(getOffset(), true);
if (getOffset() instanceof Literal) {
if (((Literal) getOffset()).getDouble() <= 0) {
if (((Literal) getOffset()).getDouble() < 0) {
throw new AnalysisException(
"The offset parameter of LEAD must be a constant positive integer: " + this.toSql());
}
Expand Down
32 changes: 32 additions & 0 deletions regression-test/data/nereids_syntax_p0/window_function.out
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,35 @@
1.0
1.5

-- !select_lead --
1
2
1
2
1
2
1
2
1
2
2
1
1
1

-- !select_lag --
1
2
1
2
1
2
1
2
1
2
2
1
1
1

Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,7 @@ suite("window_function") {
left join adj_nullable_2 on c1 = c4
where c6 is not null;
"""

qt_select_lead "SELECT lead(c1, 0, 111) over(partition by c3 order by c2) FROM window_test"
qt_select_lag "SELECT lag(c1, 0, 222) over(partition by c3 order by c2) FROM window_test"
}