From 71888063fc4d41a319e631cc3510f94a2f27509f Mon Sep 17 00:00:00 2001 From: Nick Crews Date: Sun, 11 Aug 2024 13:02:57 -0800 Subject: [PATCH] fix(duckdb): fix create_table() in database files with spaces in the name If you tried ```python import ibis conn = ibis.duckdb.connect("with space.duckdb") conn.create_table("foo", {"a": [0,1,2]}) ``` then you would get the DDL `CREATE TABLE with space.main."foo" ("a" BIGINT)`. Now, the database name is quoted. --- ibis/backends/duckdb/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index 6341605849b7e..f23b1d118c76c 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -189,8 +189,8 @@ def create_table( initial_table = sge.Table( this=sg.to_identifier(temp_name, quoted=self.compiler.quoted), - catalog=catalog, - db=database, + catalog=sg.to_identifier(catalog, quoted=self.compiler.quoted), + db=sg.to_identifier(database, quoted=self.compiler.quoted), ) target = sge.Schema(this=initial_table, expressions=column_defs) @@ -203,8 +203,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, + catalog=sg.to_identifier(catalog, quoted=self.compiler.quoted), + db=sg.to_identifier(database, quoted=self.compiler.quoted), ) with self._safe_raw_sql(create_stmt) as cur: if query is not None: