Skip to content

Commit b779571

Browse files
committed
docs: enhance docstring for DataFrame.into_view method to clarify usage and advantages
1 parent 25c16b5 commit b779571

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

python/datafusion/dataframe.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,17 @@ def into_view(self) -> TableProvider:
318318
"""Convert ``DataFrame`` into a ``TableProvider`` view for registration.
319319
320320
This is the preferred way to obtain a view for
321-
:py:meth:`~datafusion.context.SessionContext.register_table`.
321+
:py:meth:`~datafusion.context.SessionContext.register_table` for several reasons:
322+
323+
1. **Direct API**: Most efficient path - directly calls the underlying Rust
324+
``DataFrame.into_view()`` method without intermediate delegations.
325+
2. **Clear semantics**: The ``into_`` prefix follows Rust conventions,
326+
indicating conversion from one type to another.
327+
3. **Canonical method**: Other approaches like ``TableProvider.from_dataframe``
328+
delegate to this method internally, making this the single source of truth.
329+
4. **Deprecated alternatives**: The older ``TableProvider.from_view`` helper
330+
is deprecated and issues warnings when used.
331+
322332
``datafusion.TableProvider.from_dataframe`` calls this method under the hood,
323333
and the older ``TableProvider.from_view`` helper is deprecated.
324334

0 commit comments

Comments
 (0)