andygrove commented on a change in pull request #789:
URL: https://github.com/apache/arrow-datafusion/pull/789#discussion_r678397555
##########
File path: datafusion/src/execution/dataframe_impl.rs
##########
@@ -149,8 +152,19 @@ impl DataFrame for DataFrameImpl {
Ok(collect(plan).await?)
}
- // Convert the logical plan represented by this DataFrame into a physical
plan and
- // execute it
+ /// Convert the logical plan represented by this DataFrame into a physical
plan and
+ /// execute it, returning a stream over a single partition
+ async fn collect_stream(&self) -> Result<SendableRecordBatchStream> {
+ let state = self.ctx_state.lock().unwrap().clone();
+ let ctx = ExecutionContext::from(Arc::new(Mutex::new(state)));
+ let plan = ctx.optimize(&self.plan)?;
+ let plan = ctx.create_physical_plan(&plan)?;
+ collect_stream(plan).await
+ }
+
+ /// Convert the logical plan represented by this DataFrame into a physical
plan and
+ /// execute it, collecting all resulting batches into memory while
maintaining
+ /// partitioning
async fn collect_partitioned(&self) -> Result<Vec<Vec<RecordBatch>>> {
let state = self.ctx_state.lock().unwrap().clone();
Review comment:
I've cleaned the code up and removed a fair bit of duplication now.
--
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]