diff --git a/datafusion/core/src/datasource/physical_plan/file_stream.rs b/datafusion/core/src/datasource/physical_plan/file_stream.rs index 18cda4524ab2..f5144a241b3c 100644 --- a/datafusion/core/src/datasource/physical_plan/file_stream.rs +++ b/datafusion/core/src/datasource/physical_plan/file_stream.rs @@ -478,7 +478,12 @@ impl FileStream { reader, )), partition_values, - } + }; + // Return control to the runtime when we're ready to open the next file + // to prevent uncancellable queries in scenarios with many large files. + // This functions similarly to a `tokio::task::yield_now()`. + cx.waker().wake_by_ref(); + return Poll::Pending; } } }