Skip to content

Commit

Permalink
chore(polars): add database arg, for consistency (#10555)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
deepyaman authored Dec 12, 2024
1 parent dddd251 commit 2599526
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
19 changes: 13 additions & 6 deletions ibis/backends/polars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 0 additions & 9 deletions ibis/backends/tests/test_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ def _scrape_methods(modules, params):
"read_parquet",
marks=pytest.mark.notyet(["duckdb", "flink"]),
),
"table": pytest.param(
BaseBackend,
"table",
marks=pytest.mark.notyet(
[
"polars",
]
),
),
"to_parquet_dir": pytest.param(
BaseBackend,
"to_parquet_dir",
Expand Down

0 comments on commit 2599526

Please sign in to comment.