From eda3d926a8aa245e53fd5e86cbbe251a2ee2ce1f Mon Sep 17 00:00:00 2001 From: Deepyaman Datta Date: Thu, 5 Dec 2024 14:02:42 -0600 Subject: [PATCH] chore(polars): add `database` arg, for consistency --- ibis/backends/polars/__init__.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ibis/backends/polars/__init__.py b/ibis/backends/polars/__init__.py index ff65f5fb3876..9bbedd6987ae 100644 --- a/ibis/backends/polars/__init__.py +++ b/ibis/backends/polars/__init__.py @@ -86,7 +86,13 @@ def version(self) -> str: def list_tables(self, like=None, database=None): return self._filter_with_like(list(self._tables.keys()), like) - def table(self, name: str) -> ir.Table: + def table(self, name: str, database: None = None) -> ir.Table: + if database is not None: + raise com.IbisError( + "Passing `database` to the Polars backend's `table()` method is not " + "supported: Polars cannot set a database." + ) + table = self._tables.get(name) if table is None: raise com.TableNotFound(name) @@ -390,19 +396,20 @@ def create_table( ) -> ir.Table: if database is not None: raise com.IbisError( - "Passing `database` to the Polars backend create_table method has no " - "effect: Polars cannot set a database." + "Passing `database` to the Polars backend's `create_table()` method is " + "not supported: Polars cannot set a database." ) if temp is False: raise com.IbisError( - "Passing `temp=False` to the Polars backend create_table method is not " - "supported: all tables are in memory and temporary." + "Passing `temp=False` to the Polars backend's `create_table()` method " + "is not supported: all tables are in memory and temporary." ) if not overwrite and name in self._tables: raise com.IntegrityError( - f"Table {name} already exists. Use overwrite=True to clobber existing tables" + f"Table {name!r} already exists. Use `overwrite=True` to clobber " + "existing tables." ) if schema is not None and obj is None: