Skip to content

Commit

Permalink
fix(compiler-internals): define unsupported operations after simple o…
Browse files Browse the repository at this point in the history
…perations (#9755)
  • Loading branch information
cpcloud authored Aug 2, 2024
1 parent 02a1d48 commit d9b6264
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions ibis/backends/sql/compilers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,18 @@ def impl(self, _, *, _name: str = target_name, **kw):

return impl

for op, target_name in cls.SIMPLE_OPS.items():
setattr(cls, methodname(op), make_impl(op, target_name))

# unconditionally raise an exception for unsupported operations
#
# these *must* be defined after SIMPLE_OPS to handle compilers that
# subclass other compilers
for op in cls.UNSUPPORTED_OPS:
# change to visit_Unsupported in a follow up
# TODO: handle geoespatial ops as a separate case?
setattr(cls, methodname(op), cls.visit_Undefined)

for op, target_name in cls.SIMPLE_OPS.items():
setattr(cls, methodname(op), make_impl(op, target_name))

# raise on any remaining unsupported operations
for op in ALL_OPERATIONS:
name = methodname(op)
Expand Down
11 changes: 6 additions & 5 deletions ibis/backends/sql/compilers/risingwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class RisingWaveCompiler(PostgresCompiler):
),
)

SIMPLE_OPS = {
ops.First: "first_value",
ops.Last: "last_value",
}

def visit_DateNow(self, op):
return self.cast(sge.CurrentTimestamp(), dt.date)

Expand All @@ -49,6 +44,12 @@ def visit_Correlation(self, op, *, left, right, how, where):
op, left=left, right=right, how=how, where=where
)

def visit_First(self, op, *, arg, where):
return self.agg.first_value(arg, where=where)

def visit_Last(self, op, *, arg, where):
return self.agg.last_value(arg, where=where)

def visit_TimestampTruncate(self, op, *, arg, unit):
unit_mapping = {
"Y": "year",
Expand Down

0 comments on commit d9b6264

Please sign in to comment.