@@ -46,40 +46,45 @@ A complete example can be found in the `examples folder <https://github.com/apac
4646 }
4747 }
4848
49- Once you have this library available, you can construct a
50- :py:class: `~datafusion.TableProvider ` in Python and register it with the
51- ``SessionContext ``. Table providers can be created either from the PyCapsule exposed by
52- your Rust provider or from an existing :py:class: `~datafusion.dataframe.DataFrame `.
53- Call the provider's ``__datafusion_table_provider__() `` method to obtain the capsule
54- before constructing a ``TableProvider ``. The ``TableProvider.from_view() `` helper is
55- deprecated; instead use ``TableProvider.from_dataframe() `` or ``DataFrame.into_view() ``.
49+ Once you have this library available, you can instantiate the Rust-backed
50+ provider directly in Python and register it with the
51+ :py:meth: `~datafusion.context.SessionContext.register_table ` method.
52+ Objects implementing ``__datafusion_table_provider__ `` are accepted as-is, so
53+ there is no need to build a Python ``TableProvider `` wrapper just to integrate
54+ with DataFusion.
55+
56+ When you need to register a DataFusion
57+ :py:class: `~datafusion.dataframe.DataFrame `, call
58+ :py:meth: `~datafusion.dataframe.DataFrame.into_view ` to obtain an in-memory
59+ view. This is equivalent to the legacy ``TableProvider.from_dataframe() ``
60+ helper.
5661
5762.. note ::
5863
5964 :py:meth: `~datafusion.context.SessionContext.register_table_provider ` is
6065 deprecated. Use
6166 :py:meth: `~datafusion.context.SessionContext.register_table ` with the
62- resulting :py:class: `~datafusion.TableProvider ` instead.
67+ provider instance or view returned by
68+ :py:meth: `~datafusion.dataframe.DataFrame.into_view ` instead.
6369
6470.. code-block :: python
6571
66- from datafusion import SessionContext, TableProvider
72+ from datafusion import SessionContext
6773
6874 ctx = SessionContext()
6975 provider = MyTableProvider()
7076
71- capsule = provider.__datafusion_table_provider__()
72- capsule_provider = TableProvider.from_capsule(capsule)
73-
7477 df = ctx.from_pydict({" a" : [1 ]})
75- view_provider = TableProvider.from_dataframe(df)
76- # or: view_provider = df.into_view()
78+ view_provider = df.into_view()
7779
78- ctx.register_table(" capsule_table " , capsule_provider )
80+ ctx.register_table(" provider_table " , provider )
7981 ctx.register_table(" view_table" , view_provider)
8082
81- ctx.table(" capsule_table " ).show()
83+ ctx.table(" provider_table " ).show()
8284 ctx.table(" view_table" ).show()
8385
84- Both ``TableProvider.from_capsule() `` and ``TableProvider.from_dataframe() `` create
85- table providers that can be registered with the SessionContext using ``register_table() ``.
86+ The capsule-based helpers remain available for advanced integrations that need
87+ to manipulate FFI objects explicitly. ``TableProvider.from_capsule() `` continues
88+ to wrap an ``FFI_TableProvider `` (and will stay available as a compatibility
89+ alias if it is renamed in :issue: `1 `), while ``TableProvider.from_dataframe() ``
90+ simply forwards to :py:meth: `DataFrame.into_view ` for convenience.
0 commit comments