Skip to content

Commit

Permalink
feat(polars): implement create_view/drop_view/drop_table
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed May 28, 2024
1 parent 72b12a6 commit 0f11f1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
30 changes: 21 additions & 9 deletions ibis/backends/polars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,27 @@ def create_table(
self._add_table(name, obj)
return self.table(name)

def create_view(
self,
name: str,
obj: ir.Table,
*,
database: str | None = None,
overwrite: bool = False,
) -> ir.Table:
return self.create_table(
name, obj=obj, temp=None, database=database, overwrite=overwrite
)

def drop_table(self, name: str, *, force: bool = False) -> None:
if name in self._tables:
del self._tables[name]
elif not force:
raise com.IbisError(f"Table {name!r} does not exist")

def drop_view(self, name: str, *, force: bool = False) -> None:
self.drop_table(name, force=force)

def get_schema(self, table_name):
return self._tables[table_name].schema

Expand Down Expand Up @@ -532,12 +553,3 @@ def _load_into_cache(self, name, expr):

def _clean_up_cached_table(self, op):
self._remove_table(op.name)

def create_view(self, *_, **__) -> ir.Table:
raise NotImplementedError(self.name)

def drop_table(self, *_, **__) -> ir.Table:
raise NotImplementedError(self.name)

def drop_view(self, *_, **__) -> ir.Table:
raise NotImplementedError(self.name)
7 changes: 1 addition & 6 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def test_nullable_input_output(con, temp_table):
assert t.schema().types[2].nullable


@mark.notimpl(["druid", "polars"])
@mark.notimpl(["druid"])
def test_create_drop_view(ddl_con, temp_view):
# setup
table_name = "functional_alltypes"
Expand Down Expand Up @@ -1392,11 +1392,6 @@ def gen_test_name(con: BaseBackend):
con.drop_table(name, force=True)


@mark.notimpl(
["polars"],
raises=NotImplementedError,
reason="overwriting not implemented in ibis for this backend",
)
@mark.broken(
["druid"], raises=NotImplementedError, reason="generated SQL fails to parse"
)
Expand Down

0 comments on commit 0f11f1d

Please sign in to comment.