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: Fix erroneous window bounds removal during compilation #1163

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
SQLGlotCompiler,
STAR,
)
from ibis import util
from ibis.backends.sql.datatypes import BigQueryType, BigQueryUDFType
from ibis.backends.sql.rewrites import (
from bigframes_vendored.ibis.backends.sql.rewrites import (
exclude_unsupported_window_frame_from_ops,
exclude_unsupported_window_frame_from_rank,
exclude_unsupported_window_frame_from_row_number,
)
from ibis import util
from ibis.backends.sql.datatypes import BigQueryType, BigQueryUDFType
import ibis.common.exceptions as com
from ibis.common.temporal import DateUnit, IntervalUnit, TimestampUnit, TimeUnit
import ibis.expr.datatypes as dt
Expand Down Expand Up @@ -247,17 +247,6 @@ def to_sqlglot(
sources.append(result)
return sources

@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

def visit_BoundingBox(self, op, *, arg):
name = type(op).__name__[len("Geo") :].lower()
return sge.Dot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ def rewrite_empty_order_by_window(_, **kwargs):

@replace(p.WindowFunction(p.RowNumber | p.NTile))
def exclude_unsupported_window_frame_from_row_number(_, **kwargs):
return ops.Subtract(_.copy(start=None, end=0), 1)
return ops.Subtract(_.copy(start=None, end=None), 1)


@replace(p.WindowFunction(p.MinRank | p.DenseRank, start=None))
def exclude_unsupported_window_frame_from_rank(_, **kwargs):
return ops.Subtract(
_.copy(start=None, end=0, order_by=_.order_by or (ops.NULL,)), 1
_.copy(start=None, end=None, order_by=_.order_by or (ops.NULL,)), 1
)


Expand All @@ -418,7 +418,7 @@ def exclude_unsupported_window_frame_from_rank(_, **kwargs):
)
)
def exclude_unsupported_window_frame_from_ops(_, **kwargs):
return _.copy(start=None, end=0, order_by=_.order_by or (ops.NULL,))
return _.copy(start=None, end=None, order_by=_.order_by or (ops.NULL,))


# Rewrite rules for lowering a high-level operation into one composed of more
Expand Down