MCPcopy Create free account
hub / github.com/apache/datafusion / run_input

Method run_input

datafusion/physical-plan/src/stream.rs:326–382  ·  view source on GitHub ↗

Runs the `partition` of the `input` ExecutionPlan on the tokio thread pool and writes its outputs to this stream If the input partition produces an error, the error will be sent to the output stream and no further results are sent.

(
        &mut self,
        input: Arc<dyn ExecutionPlan>,
        partition: usize,
        context: Arc<TaskContext>,
    )

Source from the content-addressed store, hash-verified

324 /// If the input partition produces an error, the error will be
325 /// sent to the output stream and no further results are sent.
326 pub(crate) fn run_input(
327 &mut self,
328 input: Arc<dyn ExecutionPlan>,
329 partition: usize,
330 context: Arc<TaskContext>,
331 ) {
332 let output = self.tx();
333 let input_display = if log::log_enabled!(log::Level::Debug) {
334 displayable(input.as_ref()).one_line().to_string()
335 } else {
336 String::new()
337 };
338
339 self.inner.spawn(async move {
340 let mut stream = match input.execute(partition, context) {
341 Err(e) => {
342 // If send fails, the plan being torn down, there
343 // is no place to send the error and no reason to continue.
344 output.send(Err(e)).await.ok();
345 debug!(
346 "Stopping execution: error executing input: {input_display}",
347 );
348 return Ok(());
349 }
350 Ok(stream) => stream,
351 };
352
353 // Drop the input early, as soon as we're done with it.
354 // Holding on to it can cause delays in cancelling the child plan when the query is
355 // cancelled.
356 drop(input);
357
358 // Transfer batches from inner stream to the output tx
359 // immediately.
360 while let Some(item) = stream.next().await {
361 let is_err = item.is_err();
362
363 // If send fails, plan being torn down, there is no
364 // place to send the error and no reason to continue.
365 if output.send(item).await.is_err() {
366 debug!(
367 "Stopping execution: output is gone, plan cancelling: {input_display}",
368 );
369 return Ok(());
370 }
371
372 // Stop after the first error is encountered (Don't
373 // drive all streams to completion)
374 if is_err {
375 debug!("Stopping execution: plan returned error: {input_display}");
376 return Ok(());
377 }
378 }
379
380 Ok(())
381 });
382 }
383

Callers 5

executeMethod · 0.80
executeMethod · 0.80
consumeFunction · 0.80

Calls 11

displayableFunction · 0.85
newFunction · 0.85
txMethod · 0.80
one_lineMethod · 0.80
is_errMethod · 0.80
to_stringMethod · 0.45
as_refMethod · 0.45
spawnMethod · 0.45
executeMethod · 0.45
sendMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected