Skip to content

Commit

Permalink
perf(duckdb): make memtable registration much faster by avoiding depe…
Browse files Browse the repository at this point in the history
…ndence on `list_tables` call
  • Loading branch information
cpcloud committed Jun 21, 2024
1 parent 53bf76c commit 9805034
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,12 @@ def _register_in_memory_tables(self, expr: ir.Expr) -> None:
self._register_in_memory_table(memtable)

def _register_in_memory_table(self, op: ops.InMemoryTable) -> None:
# only register if we haven't already done so
if (name := op.name) not in self.list_tables():
name = op.name
try:
# this handles tables _and_ views
self.con.table(name)
except (duckdb.CatalogException, duckdb.InvalidInputException):
# only register if we haven't already done so
self.con.register(name, op.data.to_pyarrow(op.schema))

def _register_udfs(self, expr: ir.Expr) -> None:
Expand Down

0 comments on commit 9805034

Please sign in to comment.