Skip to content

Commit

Permalink
fix(sqlglot): ensure that sge.Median is only accessed when it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Feb 8, 2025
1 parent eecf8c3 commit dc6b7e0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ibis/backends/sql/dialects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Generator(_ClickHouse.Generator):
sge.ArraySort: rename_func("arraySort"),
sge.LogicalAnd: rename_func("min"),
sge.LogicalOr: rename_func("max"),
sge.Median: rename_func("median"),
}

def except_op(self, expression: sge.Except) -> str:
Expand All @@ -43,6 +42,10 @@ def intersect_op(self, expression: sge.Intersect) -> str:
)


with contextlib.suppress(AttributeError):
ClickHouse.Generator.TRANSFORMS[sge.Median] = rename_func("median")


class DataFusion(Postgres):
class Generator(Postgres.Generator):
TRANSFORMS = Postgres.Generator.TRANSFORMS.copy() | {
Expand All @@ -55,10 +58,13 @@ class Generator(Postgres.Generator):
sge.Array: rename_func("make_array"),
sge.ArrayContains: rename_func("array_has"),
sge.ArraySize: rename_func("array_length"),
sge.Median: rename_func("median"),
}


with contextlib.suppress(AttributeError):
DataFusion.Generator.TRANSFORMS[sge.Median] = rename_func("median")


class Druid(Postgres):
class Generator(Postgres.Generator):
TRANSFORMS = Postgres.Generator.TRANSFORMS.copy() | {
Expand Down

0 comments on commit dc6b7e0

Please sign in to comment.