File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ use datafusion::dataframe::{DataFrame, DataFrameWriteOptions};
3333use datafusion:: execution:: SendableRecordBatchStream ;
3434use datafusion:: parquet:: basic:: { BrotliLevel , Compression , GzipLevel , ZstdLevel } ;
3535use datafusion:: prelude:: * ;
36+ use futures:: StreamExt ;
3637use pyo3:: exceptions:: { PyTypeError , PyValueError } ;
3738use pyo3:: prelude:: * ;
3839use pyo3:: pybacked:: PyBackedStr ;
@@ -90,8 +91,16 @@ impl PyDataFrame {
9091 }
9192
9293 fn __repr__ ( & self , py : Python ) -> PyResult < String > {
93- let df = self . df . as_ref ( ) . clone ( ) . limit ( 0 , Some ( 10 ) ) ?;
94- let batches = wait_for_future ( py, df. collect ( ) ) ?;
94+ let df = self . df . as_ref ( ) . clone ( ) ;
95+
96+ let stream = wait_for_future ( py, df. execute_stream ( ) ) . map_err ( py_datafusion_err) ?;
97+
98+ let batches: Vec < RecordBatch > = wait_for_future (
99+ py,
100+ stream. take ( 10 ) . collect :: < Vec < _ > > ( ) )
101+ . into_iter ( )
102+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
103+
95104 let batches_as_string = pretty:: pretty_format_batches ( & batches) ;
96105 match batches_as_string {
97106 Ok ( batch) => Ok ( format ! ( "DataFrame()\n {batch}" ) ) ,
You can’t perform that action at this time.
0 commit comments