Skip to content

Commit 68cb11b

Browse files
committed
add UDTF tests for missing table capsule and table wrapper attributes
1 parent 47fbf1e commit 68cb11b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

python/tests/test_catalog.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import pyarrow as pa
2121
import pyarrow.dataset as ds
2222
import pytest
23-
from datafusion import SessionContext, Table
23+
from datafusion import SessionContext, Table, udtf
2424

2525

2626
# Note we take in `database` as a variable even though we don't use
@@ -232,3 +232,20 @@ def test_in_end_to_end_python_providers(ctx: SessionContext):
232232
assert len(batches) == 1
233233
assert batches[0].column(0) == pa.array([1, 2, 3])
234234
assert batches[0].column(1) == pa.array([4, 5, 6])
235+
236+
237+
def test_python_udtf_missing_table_capsule(ctx: SessionContext) -> None:
238+
@udtf("missing_capsule")
239+
def missing_capsule_udtf() -> Table:
240+
return Table(ctx.sql("SELECT 1 AS value"))
241+
242+
ctx.register_udtf(missing_capsule_udtf)
243+
244+
with pytest.raises(NotImplementedError, match="__datafusion_table_provider__"):
245+
ctx.sql("SELECT * FROM missing_capsule()").collect()
246+
247+
248+
def test_table_wrapper_lacks_capsule_attribute(ctx: SessionContext) -> None:
249+
table = Table(ctx.sql("SELECT 1 AS value"))
250+
251+
assert not hasattr(table, "__datafusion_table_provider__")

0 commit comments

Comments
 (0)