Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use datafusion::dataframe::{DataFrame, DataFrameWriteOptions};
use datafusion::execution::SendableRecordBatchStream;
use datafusion::parquet::basic::{BrotliLevel, Compression, GzipLevel, ZstdLevel};
use datafusion::prelude::*;
use futures::StreamExt;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use pyo3::pybacked::PyBackedStr;
Expand Down Expand Up @@ -90,8 +91,16 @@ impl PyDataFrame {
}

fn __repr__(&self, py: Python) -> PyDataFusionResult<String> {
let df = self.df.as_ref().clone().limit(0, Some(10))?;
let batches = wait_for_future(py, df.collect())?;
let df = self.df.as_ref().clone();

let stream = wait_for_future(py, df.execute_stream()).map_err(py_datafusion_err)?;

let batches: Vec<RecordBatch> = wait_for_future(
py,
stream.take(10).collect::<Vec<_>>())
.into_iter()
.collect::<Result<Vec<_>,_>>()?;

let batches_as_string = pretty::pretty_format_batches(&batches);
match batches_as_string {
Ok(batch) => Ok(format!("DataFrame()\n{batch}")),
Expand Down
Loading