zhuqi-lucas commented on code in PR #14766:
URL: https://github.com/apache/datafusion/pull/14766#discussion_r1961835327
##########
datafusion-cli/src/exec.rs:
##########
@@ -249,8 +255,21 @@ pub(super) async fn exec_and_print(
} else {
// Bounded stream; collected results are printed after all input
consumed.
let schema = physical_plan.schema();
- let results = collect(physical_plan, task_ctx.clone()).await?;
+ let mut stream = execute_stream(physical_plan, task_ctx.clone())?;
+ let mut results = vec![];
+ while let Some(batch) = stream.next().await {
+ let batch = batch?;
+ reservation.try_grow(get_record_batch_memory_size(&batch))?;
+ results.push(batch);
+ if let MaxRows::Limited(max_rows) = print_options.maxrows {
+ // Stop collecting results if the number of rows exceeds
the limit
+ if results.len() >= max_rows &&
print_options.stop_after_max_rows {
Review Comment:
Thank you @alamb for review and the great idea! It makes sense to me,
addressed in latest PR.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]