Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve](function) the offset params in lead/lag function could use 0 #33174

Merged
merged 1 commit into from
Apr 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@
24 02-24-10-21 1 \N \N \N \N \N \N \N \N
24 02-24-10-21 1 1 1 1 1.0 1 1 \N \N

-- !select_lead_lag --
1 1 1 04-21-11 21
1 1 1 04-21-11 21
0 0 0 04-22-10-21 22
0 0 0 04-22-10-21 22
1 1 1 04-22-10-21 22
1 1 1 04-22-10-21 22
1 1 1 04-23-10 23
1 1 1 04-23-10 23
1 1 1 02-24-10-21 24
1 1 1 02-24-10-21 24

Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,11 @@ suite("test_always_nullable_window_function") {
lead(state, 2, null) over (partition by myday order by time_col) lead_value
from ${nullableTableName} order by myday, time_col, state;
"""

sql "set enable_nereids_planner = true"
qt_select_lead_lag """
select lag(state, 0, 22) over (partition by myday order by time_col) lag_value,
lead(state, 0, 33) over (partition by myday order by time_col) lead_value,
state,time_col,myday
from ${nullableTableName} order by myday, time_col, state;
"""
}
Loading