diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index 28eb75e143402..87d45df1cae68 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -1578,7 +1578,7 @@ def _register_in_memory_table(self, op: ops.InMemoryTable) -> None: 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)) + self.con.register(name, op.data.to_native()) def _register_udfs(self, expr: ir.Expr) -> None: con = self.con diff --git a/ibis/formats/__init__.py b/ibis/formats/__init__.py index d8c3b24669c74..57abd68fed60a 100644 --- a/ibis/formats/__init__.py +++ b/ibis/formats/__init__.py @@ -254,6 +254,14 @@ def to_pyarrow(self, schema: Schema) -> pa.Table: # pragma: no cover def to_polars(self, schema: Schema) -> pl.DataFrame: # pragma: no cover """Convert this input to a Polars DataFrame.""" + def to_native(self) -> T: + """Convert to underlying native format. + + Useful when the backend can handle the in-memory data structure + directly. + """ + return self.obj + def to_pyarrow_bytes(self, schema: Schema) -> bytes: import pyarrow as pa import pyarrow_hotfix # noqa: F401