konjac commented on code in PR #1015: URL: https://github.com/apache/datafusion-python/pull/1015#discussion_r1959666298
########## src/dataframe.rs: ########## @@ -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<_>,_>>()?; + Review Comment: @timsaucer My bad. I used a dataset so trivial that failed to find the bug. I just pushed a new iteration, which iterates over batches until getting 10 rows. This should be identical to the previous implementation by adding limit caluse. ########## src/dataframe.rs: ########## @@ -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<_>,_>>()?; + Review Comment: @timsaucer My bad. I used a dataset so trivial that failed to find the bug. I just pushed a new iteration, which iterates over batches until getting 10 rows. This should be identical to the previous implementation by adding limit clause. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org