Skip to content

Commit

Permalink
fix(duckdb): ensure that create_schema and create_database are actual…
Browse files Browse the repository at this point in the history
…ly tested
  • Loading branch information
cpcloud authored and kszucs committed Feb 12, 2024
1 parent a8add4b commit ba31f82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ def create_schema(
"DuckDB cannot create a schema in another database."
)

name = sg.to_identifier(database, quoted=True)
return sge.Create(this=name, kind="SCHEMA", replace=force)
name = sg.table(name, catalog=database, quoted=self.compiler.quoted)
with self._safe_raw_sql(sge.Create(this=name, kind="SCHEMA", replace=force)):
pass

def drop_schema(
self, name: str, database: str | None = None, force: bool = False
Expand All @@ -502,8 +503,9 @@ def drop_schema(
"DuckDB cannot drop a schema in another database."
)

name = sg.to_identifier(database, quoted=True)
return sge.Drop(this=name, kind="SCHEMA", replace=force)
name = sg.table(name, catalog=database, quoted=self.compiler.quoted)
with self._safe_raw_sql(sge.Drop(this=name, kind="SCHEMA", replace=force)):
pass

def register(
self,
Expand Down
4 changes: 4 additions & 0 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,13 +1502,17 @@ def test_overwrite(ddl_con, monkeypatch):
def test_create_database(con_create_database):
database = gen_name("test_create_database")
con_create_database.create_database(database)
assert database in con_create_database.list_databases()
con_create_database.drop_database(database)
assert database not in con_create_database.list_databases()


def test_create_schema(con_create_schema):
schema = gen_name("test_create_schema")
con_create_schema.create_schema(schema)
assert schema in con_create_schema.list_schemas()
con_create_schema.drop_schema(schema)
assert schema not in con_create_schema.list_schemas()


@pytest.mark.notimpl(
Expand Down

0 comments on commit ba31f82

Please sign in to comment.