kosiew commented on code in PR #1243:
URL:
https://github.com/apache/datafusion-python/pull/1243#discussion_r2366570145
##########
python/datafusion/dataframe.py:
##########
@@ -313,9 +315,29 @@ def __init__(self, df: DataFrameInternal) -> None:
"""
self.df = df
- def into_view(self) -> pa.Table:
- """Convert DataFrame as a ViewTable which can be used in
register_table."""
- return self.df.into_view()
+ def into_view(self) -> TableProvider:
+ """Convert ``DataFrame`` into a ``TableProvider`` view for
registration.
+
+ This is the preferred way to obtain a view for
+ :py:meth:`~datafusion.context.SessionContext.register_table`.
Review Comment:
Here are the reasons:
1. **Direct API**: Most efficient path - directly calls the
underlying Rust
``DataFrame.into_view()`` method without intermediate delegations.
2. **Clear semantics**: The ``into_`` prefix follows Rust
conventions,
indicating conversion from one type to another.
3. **Canonical method**: Other approaches like
``TableProvider.from_dataframe``
delegate to this method internally, making this the single source
of truth.
4. **Deprecated alternatives**: The older
``TableProvider.from_view`` helper
is deprecated and issues warnings when used.
I will add the above to the comment in def to_view too
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]