Skip to content

Commit 207a3b5

Browse files
committed
feat: update documentation to reflect changes in table registration and usage of Table class
1 parent a771702 commit 207a3b5

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

docs/source/contributor-guide/ffi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ as performant as possible and to utilize the features of DataFusion, you may dec
3434
your source in Rust and then expose it through `PyO3 <https://pyo3.rs>`_ as a Python library.
3535

3636
At first glance, it may appear the best way to do this is to add the ``datafusion-python``
37-
crate as a dependency, provide a ``PyTable``, and then to register it with the
37+
crate as a dependency, produce a DataFusion table in Rust, and then register it with the
3838
``SessionContext``. Unfortunately, this will not work.
3939

4040
When you produce your code as a Python library and it needs to interact with the DataFusion

docs/source/user-guide/data-sources.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ as Delta Lake. This will require a recent version of
152152
.. code-block:: python
153153
154154
from deltalake import DeltaTable
155+
from datafusion.catalog import Table
155156
156157
delta_table = DeltaTable("path_to_table")
157-
ctx.register_table_provider("my_delta_table", delta_table)
158+
table = Table.from_capsule(delta_table)
159+
ctx.register_table("my_delta_table", table)
158160
df = ctx.table("my_delta_table")
159161
df.show()
160162

docs/source/user-guide/io/table_provider.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,26 @@ A complete example can be found in the `examples folder <https://github.com/apac
4747
}
4848
}
4949
50-
Once you have this library available, in python you can register your table provider
51-
to the ``SessionContext``.
50+
Once you have this library available, you can construct a
51+
:py:class:`~datafusion.catalog.Table` in Python and register it with the
52+
``SessionContext``. Tables can be created either from the PyCapsule exposed by
53+
your Rust provider or from an existing :py:class:`~datafusion.dataframe.DataFrame`
54+
view.
5255

5356
.. code-block:: python
5457
58+
from datafusion.catalog import Table
59+
60+
ctx = SessionContext()
5561
provider = MyTableProvider()
56-
ctx.register_table_provider("my_table", provider)
5762
58-
ctx.table("my_table").show()
63+
table_from_capsule = Table.from_capsule(provider)
64+
65+
df = ctx.from_pydict({"a": [1]})
66+
table_from_view = Table.from_view(df)
67+
68+
ctx.register_table("capsule_table", table_from_capsule)
69+
ctx.register_table("view_table", table_from_view)
70+
71+
ctx.table("capsule_table").show()
72+
ctx.table("view_table").show()

0 commit comments

Comments
 (0)