Skip to content

Commit

Permalink
chore: remove unnecessary requires_within_group AggGen property
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 2, 2024
1 parent df658d2 commit 92328c1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
18 changes: 4 additions & 14 deletions ibis/backends/sql/compilers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,13 @@ def __getattr__(self, name: str) -> Callable:

__getitem__ = __getattr__

__slots__ = ("supports_filter", "supports_order_by", "requires_within_group")
__slots__ = ("supports_filter", "supports_order_by")

def __init__(
self,
*,
supports_filter: bool = False,
supports_order_by: bool = False,
requires_within_group: bool = False,
self, *, supports_filter: bool = False, supports_order_by: bool = False
):
self.supports_filter = supports_filter
self.supports_order_by = supports_order_by
self.requires_within_group = requires_within_group

def __get__(self, instance, owner=None):
if instance is None:
Expand Down Expand Up @@ -137,13 +132,8 @@ def aggregate(
args = tuple(compiler.if_(where, arg, NULL) for arg in args)

if order_by and self.supports_order_by:
if self.requires_within_group:
out = sge.WithinGroup(
this=func(*args), expression=sge.Order(expressions=order_by)
)
else:
*rest, last = args
out = func(*rest, sge.Order(this=last, expressions=order_by))
*rest, last = args
out = func(*rest, sge.Order(this=last, expressions=order_by))
else:
out = func(*args)

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def rewrite_rows_range_order_by_window(_, **kwargs):
class MSSQLCompiler(SQLGlotCompiler):
__slots__ = ()

agg = AggGen(supports_order_by=True, requires_within_group=True)
agg = AggGen(supports_order_by=True)

dialect = MSSQL
type_mapper = MSSQLType
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class OracleCompiler(SQLGlotCompiler):
__slots__ = ()

agg = AggGen(supports_order_by=True, requires_within_group=True)
agg = AggGen(supports_order_by=True)

dialect = Oracle
type_mapper = OracleType
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SnowflakeCompiler(SQLGlotCompiler):
type_mapper = SnowflakeType
no_limit_value = NULL

agg = AggGen(supports_order_by=True, requires_within_group=True)
agg = AggGen(supports_order_by=True)

rewrites = (
exclude_unsupported_window_frame_from_row_number,
Expand Down

0 comments on commit 92328c1

Please sign in to comment.