Skip to content

Commit

Permalink
fix(duckdb): fix create_table() in database files with spaces in the …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
NickCrews committed Aug 11, 2024
1 parent 9165255 commit 7188806
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down

0 comments on commit 7188806

Please sign in to comment.