From c3a74817868048685cffdf51be32d3d29f5a365f Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 11 Sep 2024 14:56:19 -0400 Subject: [PATCH] revert: fix(datafusion): raise when attempting to create temp table (#10072) (#10099) --- ibis/backends/datafusion/__init__.py | 5 +++- .../datafusion/tests/test_register.py | 9 ------- ibis/backends/tests/test_client.py | 24 ++----------------- ibis/backends/tests/test_string.py | 9 +------ 4 files changed, 7 insertions(+), 40 deletions(-) diff --git a/ibis/backends/datafusion/__init__.py b/ibis/backends/datafusion/__init__.py index c2922e42e103..0c3aa5fcb6a3 100644 --- a/ibis/backends/datafusion/__init__.py +++ b/ibis/backends/datafusion/__init__.py @@ -612,8 +612,10 @@ def create_table( if schema is not None: schema = ibis.schema(schema) + properties = [] + if temp: - raise NotImplementedError("DataFusion does not support temporary tables") + properties.append(sge.TemporaryProperty()) quoted = self.compiler.quoted @@ -657,6 +659,7 @@ def create_table( create_stmt = sge.Create( kind="TABLE", this=target, + properties=sge.Properties(expressions=properties), expression=query, replace=overwrite, ) diff --git a/ibis/backends/datafusion/tests/test_register.py b/ibis/backends/datafusion/tests/test_register.py index f50194c80ab5..16a82973c7fa 100644 --- a/ibis/backends/datafusion/tests/test_register.py +++ b/ibis/backends/datafusion/tests/test_register.py @@ -56,12 +56,3 @@ def test_create_table_with_uppercase_name(conn): tab = pa.table({"x": [1, 2, 3]}) conn.create_table("MY_TABLE", tab) assert conn.table("MY_TABLE").x.sum().execute() == 6 - - -def test_raise_create_temp_table(conn): - tab = pa.table({"x": [1, 2, 3]}) - with pytest.raises( - NotImplementedError, - match="DataFusion does not support temporary tables", - ): - conn.create_table("my_temp_table", tab, temp=True) diff --git a/ibis/backends/tests/test_client.py b/ibis/backends/tests/test_client.py index f2d4a2adcebe..cc49bfc940f0 100644 --- a/ibis/backends/tests/test_client.py +++ b/ibis/backends/tests/test_client.py @@ -119,14 +119,7 @@ def test_create_table(backend, con, temp_table, func, sch): marks=[ pytest.mark.notyet(["clickhouse"], reason="Can't specify both"), pytest.mark.notyet( - [ - "pyspark", - "trino", - "exasol", - "risingwave", - "impala", - "datafusion", - ], + ["pyspark", "trino", "exasol", "risingwave", "impala"], reason="No support for temp tables", ), pytest.mark.notyet( @@ -152,14 +145,7 @@ def test_create_table(backend, con, temp_table, func, sch): id="temp, no overwrite", marks=[ pytest.mark.notyet( - [ - "pyspark", - "trino", - "exasol", - "risingwave", - "impala", - "datafusion", - ], + ["pyspark", "trino", "exasol", "risingwave", "impala"], reason="No support for temp tables", ), pytest.mark.notimpl(["mssql"], reason="Incorrect temp table syntax"), @@ -322,9 +308,6 @@ def test_create_table_from_schema(con, new_schema, temp_table): raises=com.IbisError, reason="`tbl_properties` is required when creating table with schema", ) -@pytest.mark.notimpl( - ["datafusion"], raises=NotImplementedError, reason="no temp table support" -) def test_create_temporary_table_from_schema(con_no_data, new_schema): if con_no_data.name == "snowflake" and os.environ.get("SNOWFLAKE_SNOWPARK"): with pytest.raises( @@ -1579,9 +1562,6 @@ def test_json_to_pyarrow(con): assert result == expected -@pytest.mark.notimpl( - ["datafusion"], raises=NotImplementedError, reason="no temp table support" -) @pytest.mark.notyet( ["risingwave", "exasol"], raises=com.UnsupportedOperationError, diff --git a/ibis/backends/tests/test_string.py b/ibis/backends/tests/test_string.py index 186afa4323cc..0c48d723bf71 100644 --- a/ibis/backends/tests/test_string.py +++ b/ibis/backends/tests/test_string.py @@ -1059,14 +1059,7 @@ def string_temp_table(backend, con): ) temp_table_name = gen_name("strings") - temp = backend.name() not in [ - "exasol", - "impala", - "pyspark", - "risingwave", - "trino", - "datafusion", - ] + temp = backend.name() not in ["exasol", "impala", "pyspark", "risingwave", "trino"] if backend.name() == "druid": yield "I HATE DRUID" else: