Skip to content

Commit 2599526

Browse files
authored
chore(polars): add database arg, for consistency (#10555)
## Description of changes Accept `database` in the `PolarsBackend.table()`, but error if it's not `None`. Also, do a bit of standardization. ## Issues closed * Resolves https://ibis-project.zulipchat.com/#narrow/channel/405263-general/topic/Are.20there.20any.20restrictions.20around.20.60Backend.2Etable.60.20signature.3F/near/486191725
1 parent dddd251 commit 2599526

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

ibis/backends/polars/__init__.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ def version(self) -> str:
8686
def list_tables(self, like=None, database=None):
8787
return self._filter_with_like(list(self._tables.keys()), like)
8888

89-
def table(self, name: str) -> ir.Table:
89+
def table(self, name: str, database: None = None) -> ir.Table:
90+
if database is not None:
91+
raise com.IbisError(
92+
"Passing `database` to the Polars backend's `table()` method is not "
93+
"supported: Polars cannot set a database."
94+
)
95+
9096
table = self._tables.get(name)
9197
if table is None:
9298
raise com.TableNotFound(name)
@@ -390,19 +396,20 @@ def create_table(
390396
) -> ir.Table:
391397
if database is not None:
392398
raise com.IbisError(
393-
"Passing `database` to the Polars backend create_table method has no "
394-
"effect: Polars cannot set a database."
399+
"Passing `database` to the Polars backend's `create_table()` method is "
400+
"not supported: Polars cannot set a database."
395401
)
396402

397403
if temp is False:
398404
raise com.IbisError(
399-
"Passing `temp=False` to the Polars backend create_table method is not "
400-
"supported: all tables are in memory and temporary."
405+
"Passing `temp=False` to the Polars backend's `create_table()` method "
406+
"is not supported: all tables are in memory and temporary."
401407
)
402408

403409
if not overwrite and name in self._tables:
404410
raise com.IntegrityError(
405-
f"Table {name} already exists. Use overwrite=True to clobber existing tables"
411+
f"Table {name!r} already exists. Use `overwrite=True` to clobber "
412+
"existing tables."
406413
)
407414

408415
if schema is not None and obj is None:

ibis/backends/tests/test_signatures.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,6 @@ def _scrape_methods(modules, params):
126126
"read_parquet",
127127
marks=pytest.mark.notyet(["duckdb", "flink"]),
128128
),
129-
"table": pytest.param(
130-
BaseBackend,
131-
"table",
132-
marks=pytest.mark.notyet(
133-
[
134-
"polars",
135-
]
136-
),
137-
),
138129
"to_parquet_dir": pytest.param(
139130
BaseBackend,
140131
"to_parquet_dir",

0 commit comments

Comments
 (0)