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>,
)
| 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 |
no test coverage detected