diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index 462e6eea4d84..f56245b6d771 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -1781,7 +1781,6 @@ def _get_temp_view_definition(self, name: str, definition: str) -> str: this=sg.to_identifier(name, quoted=self.compiler.quoted), kind="VIEW", expression=definition, - replace=True, properties=sge.Properties(expressions=[sge.TemporaryProperty()]), ) diff --git a/ibis/backends/duckdb/tests/test_io.py b/ibis/backends/duckdb/tests/test_io.py index 85a0decc3105..537bc4fc4b86 100644 --- a/ibis/backends/duckdb/tests/test_io.py +++ b/ibis/backends/duckdb/tests/test_io.py @@ -9,6 +9,7 @@ import pandas as pd import pandas.testing as tm import pyarrow as pa +import pyarrow.parquet as pq import pytest from packaging.version import parse as parse_version from pytest import param @@ -223,6 +224,22 @@ def test_read_sqlite(con, tmp_path): assert ft.count().execute() +def test_read_does_not_replace_existing_name(tmp_path): + con = ibis.duckdb.connect() + first = tmp_path / "first.parquet" + second = tmp_path / "second.parquet" + pq.write_table(pa.table({"a": [1, 2]}), first) + pq.write_table(pa.table({"b": ["x"]}), second) + + t = con.read_parquet(first, table_name="t") + + with pytest.raises(duckdb.CatalogException, match="already exists"): + con.read_parquet(second, table_name="t") + + assert t.columns == ("a",) + assert t.count().execute() == 2 + + def test_read_sqlite_no_table_name(con, tmp_path): path = tmp_path / "test.db"