File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ Here is a direct link to the file used in the examples:
4242
4343- [ Register a Python UDF with DataFusion] ( ./python-udf.py )
4444- [ Register a Python UDAF with DataFusion] ( ./python-udaf.py )
45+ - [ Reproduce missing table-provider capsule failures in Python integrations] ( ./python-udtf-table-capsule-regression.py )
46+ - Demonstrates how a Python UDTF and catalog consumer currently raise
47+ exceptions when ` __datafusion_table_provider__ ` is unavailable.
4548
4649### Substrait Support
4750
Original file line number Diff line number Diff line change 1+ """Regression example highlighting missing table provider capsule behavior.
2+ """
3+
4+ from __future__ import annotations
5+
6+ from datafusion import SessionContext , Table , udtf
7+
8+
9+ def main () -> None :
10+ """Demonstrate current failure modes around table provider capsules."""
11+
12+ ctx = SessionContext ()
13+
14+ @udtf ("table_from_sql" )
15+ def table_from_sql_udtf () -> Table :
16+ """Return a DataFusion Table constructed from a SQL query."""
17+
18+ return Table (ctx .sql ("SELECT 1 AS value" ))
19+
20+ ctx .register_udtf (table_from_sql_udtf )
21+
22+ try :
23+ ctx .sql ("SELECT * FROM table(table_from_sql())" ).collect ()
24+ except NotImplementedError as err :
25+ print ("Collecting from table_from_sql() failed:" , err )
26+
27+ ctx .register_table ("numbers" , Table (ctx .sql ("SELECT 1 AS value" )))
28+
29+ numbers = ctx .catalog ().schema ("public" ).table ("numbers" )
30+
31+ try :
32+ getattr (numbers , "__datafusion_table_provider__" )
33+ except AttributeError as err :
34+ print ("Accessing __datafusion_table_provider__ on catalog table failed:" , err )
35+
36+
37+ if __name__ == "__main__" :
38+ main ()
You can’t perform that action at this time.
0 commit comments