Skip to content

Commit 6869919

Browse files
committed
refactor: replace to_view_provider with inner_df for DataFrame access
1 parent 00bd445 commit 6869919

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/dataframe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use datafusion::arrow::util::pretty;
3131
use datafusion::common::UnnestOptions;
3232
use datafusion::config::{CsvOptions, ParquetColumnOptions, ParquetOptions, TableParquetOptions};
3333
use datafusion::dataframe::{DataFrame, DataFrameWriteOptions};
34-
use datafusion::datasource::TableProvider;
3534
use datafusion::error::DataFusionError;
3635
use datafusion::execution::SendableRecordBatchStream;
3736
use datafusion::parquet::basic::{BrotliLevel, Compression, GzipLevel, ZstdLevel};
@@ -268,8 +267,9 @@ impl PyDataFrame {
268267
}
269268
}
270269

271-
pub(crate) fn to_view_provider(&self) -> Arc<dyn TableProvider> {
272-
self.df.as_ref().clone().into_view()
270+
/// Return a clone of the inner Arc<DataFrame> for crate-local callers.
271+
pub(crate) fn inner_df(&self) -> Arc<DataFrame> {
272+
Arc::clone(&self.df)
273273
}
274274

275275
fn prepare_repr_string(&mut self, py: Python, as_html: bool) -> PyDataFusionResult<String> {
@@ -407,7 +407,7 @@ impl PyDataFrame {
407407
// Call the underlying Rust DataFrame::into_view method.
408408
// Note that the Rust method consumes self; here we clone the inner Arc<DataFrame>
409409
// so that we don't invalidate this PyDataFrame.
410-
let table_provider = self.to_view_provider();
410+
let table_provider = self.df.as_ref().clone().into_view();
411411
Ok(PyTableProvider::new(table_provider))
412412
}
413413

src/table.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ impl PyTableProvider {
8080
/// This method simply delegates to `DataFrame.into_view`.
8181
#[staticmethod]
8282
pub fn from_dataframe(df: &PyDataFrame) -> Self {
83-
let table_provider = df.to_view_provider();
83+
// Clone the inner DataFrame and convert it into a view TableProvider.
84+
// `into_view` consumes a DataFrame, so clone the underlying DataFrame
85+
// (this mirrors the previous implementation which used
86+
// `self.df.as_ref().clone().into_view()`).
87+
let table_provider = df.inner_df().as_ref().clone().into_view();
8488
Self::new(table_provider)
8589
}
8690

0 commit comments

Comments
 (0)