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

fix(mssql): restore unbounded window functions #8411

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

gforsyth
Copy link
Member

Description of changes

MSSQL requires an order-by clause in unbounded windows. This is clearly
documented in
https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-10000-to-10999
(just kidding, it's a huge list of error codes you have to scroll through. You
want Error 10756)

The behavior of the mssql sqlalchemy connector is to order by the field used in
the window function. This seems silly, and potentially slightly
computationally wasteful, but not incorrect.

So, I've added a rewrite rule to the MSSQL compiler that copies this behavior
for all reduction functions that aren't UDFs, since those aren't supported
anyway (and would require a different rewrite rule, in any case).

Issues closed

MSSQL requires an order-by clause in unbounded windows.  The behavior of
the mssql sqlalchemy connector is to order by the field used in the
window function.
This seems silly, and potentially slightly computationally wasteful, but
not incorrect.
Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for digging around in the muck!

@cpcloud cpcloud added bug Incorrect behavior inside of ibis mssql The Microsoft SQL Server backend labels Feb 21, 2024
@cpcloud cpcloud merged commit 0211d4f into ibis-project:main Feb 21, 2024
78 checks passed
@gforsyth gforsyth deleted the mssql/unbounded_window branch February 21, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis mssql The Microsoft SQL Server backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression(mssql): investigate bringing back unbounded window frame window functions
2 participants