Skip to content

Commit

Permalink
fix(duckdb): clean up temp view junk when using memtables in `create_…
Browse files Browse the repository at this point in the history
…table` (#9107)

QoL improvement for loading from in-memory data: no more temporary view
junk.
  • Loading branch information
cpcloud committed May 2, 2024
1 parent 66a67c0 commit 4e7a00c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion docs/tutorials/getting_started.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ con.create_table(
You can now see the example dataset copied over to the database:

```{python}
con = ibis.connect("duckdb://penguins.ddb")
con.list_tables()
```

Expand Down
6 changes: 6 additions & 0 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ def create_table(
if temp:
properties.append(sge.TemporaryProperty())

temp_memtable_view = None

if obj is not None:
if not isinstance(obj, ir.Expr):
table = ibis.memtable(obj)
temp_memtable_view = table.op().name
else:
table = obj

Expand Down Expand Up @@ -248,6 +251,9 @@ def create_table(
).sql(self.name)
)

if temp_memtable_view is not None:
self.con.unregister(temp_memtable_view)

return self.table(name, database=database)

def _load_into_cache(self, name, expr):
Expand Down

0 comments on commit 4e7a00c

Please sign in to comment.