Skip to content

Commit 5de9b53

Browse files
committed
docs: enhance DataFrame documentation with usage examples for into_view method
1 parent be51736 commit 5de9b53

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/datafusion/dataframe.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,18 @@ def into_view(self) -> TableProvider:
315315
:py:meth:`~datafusion.context.SessionContext.register_table`.
316316
``datafusion.TableProvider.from_dataframe`` calls this method under the hood,
317317
and the older ``TableProvider.from_view`` helper is deprecated.
318+
319+
The ``DataFrame`` remains valid after conversion, so it can still be used for
320+
additional queries alongside the returned view.
321+
322+
Examples:
323+
>>> from datafusion import SessionContext
324+
>>> ctx = SessionContext()
325+
>>> df = ctx.sql("SELECT 1 AS value")
326+
>>> provider = df.into_view()
327+
>>> ctx.register_table("values_view", provider)
328+
>>> df.collect() # The DataFrame is still usable
329+
>>> ctx.sql("SELECT value FROM values_view").collect()
318330
"""
319331
from datafusion.table_provider import TableProvider as _TableProvider
320332

0 commit comments

Comments
 (0)