From 4e7a00cb4a383a01466c39b0929f582e66f7ba07 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 2 May 2024 13:03:18 -0400 Subject: [PATCH] fix(duckdb): clean up temp view junk when using memtables in `create_table` (#9107) QoL improvement for loading from in-memory data: no more temporary view junk. --- docs/tutorials/getting_started.qmd | 1 - ibis/backends/duckdb/__init__.py | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/getting_started.qmd b/docs/tutorials/getting_started.qmd index f55c79d3a59e..ab66577b7ff9 100644 --- a/docs/tutorials/getting_started.qmd +++ b/docs/tutorials/getting_started.qmd @@ -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() ``` diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index 649d02fa0edd..cdec3aee291a 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -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 @@ -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):