Skip to content

Commit d9b6264

Browse files
authored
fix(compiler-internals): define unsupported operations after simple operations (#9755)
1 parent 02a1d48 commit d9b6264

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

ibis/backends/sql/compilers/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,18 @@ def impl(self, _, *, _name: str = target_name, **kw):
434434

435435
return impl
436436

437+
for op, target_name in cls.SIMPLE_OPS.items():
438+
setattr(cls, methodname(op), make_impl(op, target_name))
439+
437440
# unconditionally raise an exception for unsupported operations
441+
#
442+
# these *must* be defined after SIMPLE_OPS to handle compilers that
443+
# subclass other compilers
438444
for op in cls.UNSUPPORTED_OPS:
439445
# change to visit_Unsupported in a follow up
440446
# TODO: handle geoespatial ops as a separate case?
441447
setattr(cls, methodname(op), cls.visit_Undefined)
442448

443-
for op, target_name in cls.SIMPLE_OPS.items():
444-
setattr(cls, methodname(op), make_impl(op, target_name))
445-
446449
# raise on any remaining unsupported operations
447450
for op in ALL_OPERATIONS:
448451
name = methodname(op)

ibis/backends/sql/compilers/risingwave.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class RisingWaveCompiler(PostgresCompiler):
3232
),
3333
)
3434

35-
SIMPLE_OPS = {
36-
ops.First: "first_value",
37-
ops.Last: "last_value",
38-
}
39-
4035
def visit_DateNow(self, op):
4136
return self.cast(sge.CurrentTimestamp(), dt.date)
4237

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

47+
def visit_First(self, op, *, arg, where):
48+
return self.agg.first_value(arg, where=where)
49+
50+
def visit_Last(self, op, *, arg, where):
51+
return self.agg.last_value(arg, where=where)
52+
5253
def visit_TimestampTruncate(self, op, *, arg, unit):
5354
unit_mapping = {
5455
"Y": "year",

0 commit comments

Comments
 (0)