From 2f69cde9a2436164e17b6c92cb3ac8b51b33cd62 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 26 Sep 2024 05:41:39 -0400 Subject: [PATCH] chore: catch `AttributeError` instead of checking --- ibis/backends/duckdb/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index b1f5a1f074532..09d1f22fab74e 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -1609,10 +1609,15 @@ def _in_memory_table_exists(self, name: str) -> bool: return True def _register_in_memory_table(self, op: ops.InMemoryTable) -> None: - if hasattr(op.data, "to_pyarrow_dataset"): - self.con.register(op.name, op.data.to_pyarrow_dataset(op.schema)) - else: - self.con.register(op.name, op.data.to_pyarrow(op.schema)) + data = op.data + schema = op.schema + + try: + obj = data.to_pyarrow_dataset(schema) + except AttributeError: + obj = data.to_pyarrow(schema) + + self.con.register(op.name, obj) def _finalize_memtable(self, name: str) -> None: # if we don't aggressively unregister tables duckdb will keep a