diff --git a/ibis/backends/clickhouse/__init__.py b/ibis/backends/clickhouse/__init__.py index 05016732727b..f68dcfd0c8d7 100644 --- a/ibis/backends/clickhouse/__init__.py +++ b/ibis/backends/clickhouse/__init__.py @@ -674,7 +674,7 @@ def create_table( schema = obj.schema() this = sge.Schema( - this=sg.table(name, db=database), + this=sg.table(name, db=database, quoted=self.compiler.quoted), expressions=[ sge.ColumnDef( this=sg.to_identifier(name, quoted=self.compiler.quoted), diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index f1e2f647b156..c2396ba8b417 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -187,10 +187,8 @@ def create_table( else: temp_name = name - initial_table = sge.Table( - this=sg.to_identifier(temp_name, quoted=self.compiler.quoted), - catalog=catalog, - db=database, + initial_table = sg.table( + temp_name, catalog=catalog, db=database, quoted=self.compiler.quoted ) target = sge.Schema(this=initial_table, expressions=column_defs) @@ -201,10 +199,8 @@ def create_table( ) # This is the same table as initial_table unless overwrite == True - final_table = sge.Table( - this=sg.to_identifier(name, quoted=self.compiler.quoted), - catalog=catalog, - db=database, + final_table = sg.table( + name, catalog=catalog, db=database, quoted=self.compiler.quoted ) with self._safe_raw_sql(create_stmt) as cur: if query is not None: diff --git a/ibis/backends/duckdb/tests/test_client.py b/ibis/backends/duckdb/tests/test_client.py index c8b4a4e91183..cfb2f10d72ff 100644 --- a/ibis/backends/duckdb/tests/test_client.py +++ b/ibis/backends/duckdb/tests/test_client.py @@ -326,6 +326,20 @@ def test_connect_named_in_memory_db(): assert "ork" not in default_memory_db.list_tables() +@pytest.mark.parametrize( + "database_file", + [ + "with spaces.ddb", + "space catalog.duckdb.db", + ], +) +def test_create_table_quoting(database_file, tmp_path): + conn = ibis.duckdb.connect(tmp_path / database_file) + t = conn.create_table("t", {"a": [0, 1, 2]}) + result = set(conn.execute(t.a)) + assert result == {0, 1, 2} + + @pytest.mark.parametrize( ("url", "method_name"), [