Skip to content

Commit

Permalink
fix(datafusion): raise when attempting to create temp table (#10072)
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Cloud <[email protected]>
  • Loading branch information
ncclementi and cpcloud authored Sep 10, 2024
1 parent 019cae5 commit 1cf5439
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
5 changes: 1 addition & 4 deletions ibis/backends/datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,8 @@ def create_table(
if schema is not None:
schema = ibis.schema(schema)

properties = []

if temp:
properties.append(sge.TemporaryProperty())
raise NotImplementedError("DataFusion does not support temporary tables")

quoted = self.compiler.quoted

Expand Down Expand Up @@ -669,7 +667,6 @@ def create_table(
create_stmt = sge.Create(
kind="TABLE",
this=target,
properties=sge.Properties(expressions=properties),
expression=query,
replace=overwrite,
)
Expand Down
9 changes: 9 additions & 0 deletions ibis/backends/datafusion/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ 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)
24 changes: 22 additions & 2 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ 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"],
[
"pyspark",
"trino",
"exasol",
"risingwave",
"impala",
"datafusion",
],
reason="No support for temp tables",
),
pytest.mark.notyet(
Expand All @@ -145,7 +152,14 @@ def test_create_table(backend, con, temp_table, func, sch):
id="temp, no overwrite",
marks=[
pytest.mark.notyet(
["pyspark", "trino", "exasol", "risingwave", "impala"],
[
"pyspark",
"trino",
"exasol",
"risingwave",
"impala",
"datafusion",
],
reason="No support for temp tables",
),
pytest.mark.notimpl(["mssql"], reason="Incorrect temp table syntax"),
Expand Down Expand Up @@ -308,6 +322,9 @@ 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(
Expand Down Expand Up @@ -1562,6 +1579,9 @@ 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,
Expand Down
9 changes: 8 additions & 1 deletion ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,14 @@ def string_temp_table(backend, con):
)

temp_table_name = gen_name("strings")
temp = backend.name() not in ["exasol", "impala", "pyspark", "risingwave", "trino"]
temp = backend.name() not in [
"exasol",
"impala",
"pyspark",
"risingwave",
"trino",
"datafusion",
]
if backend.name() == "druid":
yield "I HATE DRUID"
else:
Expand Down

0 comments on commit 1cf5439

Please sign in to comment.