Skip to content

Commit 7b09073

Browse files
committed
Exposing FFI to python
1 parent 05f5356 commit 7b09073

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

examples/datafusion-ffi-example/python/tests/_test_catalog_provider.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
from datafusion import SessionContext
2323
from datafusion_ffi_example import MyCatalogProvider
2424

25+
2526
def test_catalog_provider():
2627
ctx = SessionContext()
2728

2829
my_catalog_name = "my_catalog"
2930
expected_schema_name = "my_schema"
3031
expected_table_name = "my_table"
31-
expected_table_columns = ['units', 'price']
32+
expected_table_columns = ["units", "price"]
3233

3334
catalog_provider = MyCatalogProvider()
3435
ctx.register_catalog_provider(my_catalog_name, catalog_provider)
@@ -41,12 +42,9 @@ def test_catalog_provider():
4142
my_table = my_database.table(expected_table_name)
4243
assert expected_table_columns == my_table.schema.names
4344

44-
ctx.register_table(expected_table_name, my_table)
45-
expected_df = ctx.sql(f"SELECT * FROM {expected_table_name}").to_pandas()
46-
assert len(expected_df) == 5
47-
assert expected_table_columns == expected_df.columns.tolist()
48-
49-
result = ctx.table(f"{my_catalog_name}.{expected_schema_name}.{expected_table_name}").collect()
45+
result = ctx.table(
46+
f"{my_catalog_name}.{expected_schema_name}.{expected_table_name}"
47+
).collect()
5048
assert len(result) == 2
5149

5250
col0_result = [r.column(0) for r in result]
@@ -60,4 +58,4 @@ def test_catalog_provider():
6058
pa.array([1.5, 2.5], type=pa.float64()),
6159
]
6260
assert col0_result == expected_col0
63-
assert col1_result == expected_col1
61+
assert col1_result == expected_col1

python/datafusion/context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class CatalogProviderExportable(Protocol):
8383
8484
https://docs.rs/datafusion/latest/datafusion/catalog/trait.CatalogProvider.html
8585
"""
86-
def __datafusion_catalog_provider__(self) -> object: ...
86+
87+
def __datafusion_catalog_provider__(self) -> object: ... # noqa: D105
8788

8889

8990
class SessionConfig:
@@ -751,7 +752,7 @@ def deregister_table(self, name: str) -> None:
751752
self.ctx.deregister_table(name)
752753

753754
def register_catalog_provider(
754-
self, name: str, provider: CatalogProviderExportable
755+
self, name: str, provider: CatalogProviderExportable
755756
) -> None:
756757
"""Register a catalog provider."""
757758
self.ctx.register_catalog_provider(name, provider)

0 commit comments

Comments
 (0)