diff --git a/ibis/backends/tests/test_api.py b/ibis/backends/tests/test_api.py index 108a194ecb0c..b75c99d8c28c 100644 --- a/ibis/backends/tests/test_api.py +++ b/ibis/backends/tests/test_api.py @@ -136,3 +136,8 @@ def test_unbind(alltypes, expr_fn): assert "Unbound" not in repr(expr) assert "Unbound" in repr(expr.unbind()) + + +def test_get_backend(con, alltypes): + assert alltypes.get_backend() is con + assert alltypes.id.min().get_backend() is con diff --git a/ibis/expr/types/core.py b/ibis/expr/types/core.py index 9c9c380b114e..27ccbc2e5c08 100644 --- a/ibis/expr/types/core.py +++ b/ibis/expr/types/core.py @@ -375,6 +375,17 @@ def _find_backend(self, *, use_default: bool = False) -> BaseBackend: return backends[0] + def get_backend(self): + """Get the current Ibis backend of the expression. + + Returns + ------- + BaseBackend + The Ibis backend. + + """ + return self._find_backend(use_default=True) + def execute( self, limit: int | str | None = "default",