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

window: the right border can't work? #2365

Closed
vagetablechicken opened this issue Aug 17, 2022 · 3 comments
Closed

window: the right border can't work? #2365

vagetablechicken opened this issue Aug 17, 2022 · 3 comments

Comments

@vagetablechicken
Copy link
Collaborator

We have this example:

            Example:

            |c1|c2|
            |--|--|
            |0 | 1|
            |1 | 1|
            |2 | 2|
            |3 | 2|
            |4 | 2|

SELECT at(c1, 1) over w as co from t1 window w as(partition by c2 order by c1 rows between unbounded preceding and current row);
                -- output
                -- | co |
                -- |----|
                -- |NULL|
                -- |0   |
                -- |NULL|
                -- |2   |
                -- |3   |

But run SELECT at(c1, 1) over w as co from t1 window w as(partition by c2 order by c1 rows between unbounded preceding and 1000 preceding); is the same result. Why?

@aceforeverd
Copy link
Collaborator

aceforeverd commented Aug 17, 2022

lag/lead or the old at function, is always relative to current row, window frame bound do not take any real meaning to the SQL engine.

Both SQL is equivalent to select at(c1, 1) over (partition by c2 order by c1) from t1.

at over ( .... between A and B) is allowed just for backward compatibility. Also to mention, it is not allowed in Spark SQL

@aceforeverd
Copy link
Collaborator

more discussion here #1554

@vagetablechicken
Copy link
Collaborator Author

Added more info in udf docs, close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants