-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mssql): exclude window frame from rank (#10302)
## 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 <rows or range clause/> of the OVER clause cannot be specified for the RANK function. For more information, see [OVER Clause (Transact-SQL)](https://learn.microsoft.com/en-us/sql/t-sql/queries/select-over-clause-transact-sql?view=sql-server-ver16). ## Issues closed Resolves #10291
- Loading branch information
Showing
3 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
ibis/backends/mssql/tests/snapshots/test_window/test_rank_no_window_frame/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT | ||
[t0].[color], | ||
[t0].[price], | ||
RANK() OVER (PARTITION BY [t0].[color] ORDER BY CASE WHEN [t0].[price] IS NULL THEN 1 ELSE 0 END, [t0].[price] ASC) - 1 AS [MinRank()] | ||
FROM [diamonds_sample] AS [t0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
import ibis | ||
|
||
|
||
def test_rank_no_window_frame(con, snapshot): | ||
t = ibis.table(schema=dict(color=str, price=int), name="diamonds_sample") | ||
expr = t.mutate(ibis.rank().over(group_by="color", order_by="price")) | ||
sql = ibis.to_sql(expr, dialect="mssql") | ||
|
||
snapshot.assert_match(sql, "out.sql") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters