Skip to content

Commit

Permalink
chore(api): remove defunct add_operation from backends (ibis-project#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth authored Jun 11, 2024
1 parent 20f01b9 commit ad27f9f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
2 changes: 0 additions & 2 deletions ibis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def __getattr__(name: str) -> BaseBackend:
# - connect
# - compile
# - has_operation
# - add_operation
# - _from_url
# - _to_sqlglot
#
Expand All @@ -116,7 +115,6 @@ def connect(*args, **kwargs):
proxy.connect = connect
proxy.compile = backend.compile
proxy.has_operation = backend.has_operation
proxy.add_operation = backend.add_operation
proxy.name = name
proxy._from_url = backend._from_url
proxy._to_sqlglot = backend._to_sqlglot
Expand Down
19 changes: 1 addition & 18 deletions ibis/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ibis.common.caching import RefCountedCache

if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping
from collections.abc import Iterable, Iterator, Mapping, MutableMapping

import pandas as pd
import polars as pl
Expand Down Expand Up @@ -1051,23 +1051,6 @@ def _to_sqlglot(self, expr: ir.Expr, **kwargs) -> sg.exp.Expression:
def execute(self, expr: ir.Expr) -> Any:
"""Execute an expression."""

def add_operation(self, operation: ops.Node) -> Callable:
"""Add a translation function to the backend for a specific operation.
Operations are defined in `ibis.expr.operations`, and a translation
function receives the translator object and an expression as
parameters, and returns a value depending on the backend.
"""
if not hasattr(self, "compiler"):
raise RuntimeError("Only SQL-based backends support `add_operation`")

def decorator(translation_function: Callable) -> None:
self.compiler.translator_class.add_operation(
operation, translation_function
)

return decorator

@abc.abstractmethod
def create_table(
self,
Expand Down
2 changes: 1 addition & 1 deletion ibis/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# def test_public_backend_methods():
# public = {m for m in dir(ibis.sqlite) if not m.startswith("_")}
# assert public == {"connect", "compile", "has_operation", "add_operation", "name"}
# assert public == {"connect", "compile", "has_operation", "name"}


def test_missing_backend():
Expand Down

0 comments on commit ad27f9f

Please sign in to comment.