Skip to content

fix(mssql): exclude window frame from rank #10302

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

Merged
merged 2 commits into from
Oct 13, 2024

Conversation

IndexSeek
Copy link
Member

Description of changes

Resolves an error where the RANK window function added a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING window frame, which is unsupported by MSSQL.

The of the OVER clause cannot be specified for the RANK function. For more information, see OVER Clause (Transact-SQL).

Issues closed

Resolves #10291

@github-actions github-actions bot added the sql Backends that generate SQL label Oct 11, 2024
Copy link
Member

@gforsyth gforsyth left a comment

Choose a reason for hiding this comment

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

Nice! Thanks @IndexSeek !

I imagine you tested this out locally, but maybe we should add a snapshot test to confirm that we're generating the correct SQL?

@IndexSeek
Copy link
Member Author

Thank you @gforsyth, happy to help!

I was thinking a test for this scenario would be worthwhile, but wasn't sure how best to go about it.

Would we want to set something up a test to check that the text ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING should not appear in the compiled SQL for these backends that do not support the window frame?

@gforsyth
Copy link
Member

gforsyth commented Oct 11, 2024

Yeah, these can be tricky to test.

You can look at

@pytest.mark.parametrize("typ", ["float32", "float64"])

For an example of a snapshot test. I think if you have an expression that will generate a rank query, then we can check in the snapshot and that will confirm for us that the window bounds are excluded on mssql

I think this can/should be mssql specific

@github-actions github-actions bot added tests Issues or PRs related to tests mssql The Microsoft SQL Server backend labels Oct 11, 2024
@IndexSeek
Copy link
Member Author

Thank you for pointing me to an example. I gave this a try; hopefully, it covers this scenario. I'm happy to make any changes as needed!

Copy link
Member

@gforsyth gforsyth left a comment

Choose a reason for hiding this comment

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

Nice! Thanks @IndexSeek !

@gforsyth gforsyth merged commit 244876a into ibis-project:main Oct 13, 2024
77 checks passed
@IndexSeek IndexSeek deleted the patch-2 branch October 30, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mssql The Microsoft SQL Server backend sql Backends that generate SQL tests Issues or PRs related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: MSSQL RANK OVER does not support row clause
2 participants