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

exec: support window frames for window functions in vectorized engine #37037

Closed
yuzefovich opened this issue Apr 23, 2019 · 4 comments · Fixed by #66510
Closed

exec: support window frames for window functions in vectorized engine #37037

yuzefovich opened this issue Apr 23, 2019 · 4 comments · Fixed by #66510
Labels
A-sql-vec SQL vectorized engine C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team

Comments

@yuzefovich
Copy link
Member

No description provided.

@yuzefovich yuzefovich added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-execution Relating to SQL execution. labels Apr 23, 2019
@yuzefovich yuzefovich self-assigned this Apr 23, 2019
@yuzefovich yuzefovich added A-sql-vec SQL vectorized engine and removed A-sql-execution Relating to SQL execution. labels Apr 23, 2019
@yuzefovich yuzefovich removed their assignment Mar 14, 2020
@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
@craig craig bot closed this as completed in 31cdc0e Jul 15, 2021
@yuzefovich yuzefovich reopened this Jul 15, 2021
@yuzefovich
Copy link
Member Author

@DrewKimball I reopened this issue because the already supported window functions also need to be taught about the window frames (e.g. select rank() over (order by a range 1 preceding) from t; is still currently handled by the rowexec windower).

@DrewKimball
Copy link
Collaborator

I see. Sounds good

@DrewKimball
Copy link
Collaborator

Oh, actually I think we're good to close this after all once first_value, last_value and nth_value are done. Non-aggregate window functions other than first_value, last_value and nth_value seem to all ignore the window frame:

postgres=# select x, y, rank() over (order by y ROWS BETWEEN 1000 FOLLOWING AND 1000 FOLLOWING) from t;
 x |          y          | rank
---+---------------------+------
 1 |                   1 |    1
 4 |                   1 |    1
 5 |                  20 |    3
 3 | 9223372036854775807 |    4
 2 |                     |    5
(5 rows)

Postgres doesn't really have any documentation for this, but here's a relevant quote from MySql docs:

Standard SQL specifies that window functions that operate on the entire partition should have no frame clause. MySQL permits a frame clause for such functions but ignores it. These functions use the entire partition even if a frame is specified:
CUME_DIST()
DENSE_RANK()
LAG()
LEAD()
NTILE()
PERCENT_RANK()
RANK()
ROW_NUMBER()

@yuzefovich
Copy link
Member Author

Oh yeah, I think you're right. We don't look at the frames for those window functions in the row engine either, and I guess we just unnecessarily prohibited frames for them in the vectorized engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-vec SQL vectorized engine C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants