Skip to content

Commit 7b0cbf1

Browse files
committed
refactor: simplify into_view method and update Rust binding convention
1 parent 6bba2e2 commit 7b0cbf1

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

python/datafusion/dataframe.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ def __init__(self, df: DataFrameInternal) -> None:
123123

124124
def into_view(self) -> pa.Table:
125125
"""Convert DataFrame as a ViewTable which can be used in register_table."""
126-
return self._into_view()
127-
128-
def _into_view(self) -> pa.Table:
129-
"""Convert DataFrame as a ViewTable which can be used in register_table."""
130-
return self.df._into_view()
126+
return self.df.into_view()
131127

132128
def __getitem__(self, key: str | List[str]) -> DataFrame:
133129
"""Return a new :py:class`DataFrame` with the specified column or columns.

src/dataframe.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,15 @@ impl PyDataFrame {
175175
}
176176

177177
/// Convert this DataFrame into a Table that can be used in register_table
178-
fn _into_view(&self) -> PyDataFusionResult<PyTable> {
178+
/// By convention, into_... methods consume self and return the new object.
179+
/// Disabling the clippy lint, so we can use &self
180+
/// because we're working with Python bindings
181+
/// where objects are shared
182+
#[allow(clippy::wrong_self_convention)]
183+
fn into_view(&self) -> PyDataFusionResult<PyTable> {
179184
// Call the underlying Rust DataFrame::into_view method.
180185
// Note that the Rust method consumes self; here we clone the inner Arc<DataFrame>
181186
// so that we don’t invalidate this PyDataFrame.
182-
// _into_view because clippy says `into_*` usually take `self` by value
183-
// but we cannot own self because Python objects are shared,
184-
// so 'self' cannot be moved out of the Python interpreter
185187
let table_provider = self.df.as_ref().clone().into_view();
186188
let table_provider = PyTableProvider::new(table_provider);
187189

0 commit comments

Comments
 (0)