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(compiler-internals): define unsupported operations after simple operations #9755

Merged
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
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implemented this way as a test case for the definition order, but it turns out to be needed in #9729.


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