Skip to content

Commit

Permalink
refactor(snowflake): adjust window frames to use _minimize_spec due…
Browse files Browse the repository at this point in the history
… to upstream snowflake changes
  • Loading branch information
cpcloud authored and kszucs committed Feb 12, 2024
1 parent 5937ce3 commit 3a6c9f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions ibis/backends/snowflake/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ def _aggregate(self, funcname: str, *args, where):
def visit_node(self, op, **kw):
return super().visit_node(op, **kw)

@staticmethod
def _minimize_spec(start, end, spec):
if (
start is None
and isinstance(getattr(end, "value", None), ops.Literal)
and end.value.value == 0
and end.following
):
return None
return spec

@visit_node.register(ops.Literal)
def visit_Literal(self, op, *, value, dtype):
if value is None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
WITH "t6" AS (
SELECT
"t5"."street",
ROW_NUMBER() OVER (ORDER BY "t5"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "key"
ROW_NUMBER() OVER (ORDER BY "t5"."street" ASC) - 1 AS "key"
FROM (
SELECT
"t2"."street",
"t2"."key"
FROM (
SELECT
"t0"."street",
ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "key"
ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC) - 1 AS "key"
FROM "data" AS "t0"
) AS "t2"
INNER JOIN (
Expand All @@ -18,7 +18,7 @@ WITH "t6" AS (
FROM (
SELECT
"t0"."street",
ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "key"
ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC) - 1 AS "key"
FROM "data" AS "t0"
) AS "t1"
) AS "t4"
Expand All @@ -27,7 +27,7 @@ WITH "t6" AS (
), "t1" AS (
SELECT
"t0"."street",
ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "key"
ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC) - 1 AS "key"
FROM "data" AS "t0"
)
SELECT
Expand Down

0 comments on commit 3a6c9f3

Please sign in to comment.