zhuqi-lucas opened a new pull request, #21827: URL: https://github.com/apache/datafusion/pull/21827
## Which issue does this PR close? Closes #21826 ## Rationale for this change `InterleaveExec::with_new_children` panics with an assertion error when children's output partitioning diverges after optimizer rewrites. This happens in practice when multiple physical optimizer passes modify the plan between when `InterleaveExec` is created and when `with_new_children` is called. We hit this in production with a complex UNION ALL query (5 subqueries with JOINs across partitioned tables, single-file tables, and materialized views). Our custom optimizer chain runs `EnforceDistribution` twice — the first pass creates `InterleaveExec`, later optimizers modify children's partitioning, then the second pass triggers the assertion panic. ## What changes are included in this PR? `InterleaveExec::with_new_children` now gracefully falls back to `UnionExec` when children are no longer interleavable, instead of panicking. A warning is logged when the fallback occurs. Correctness is preserved — `EnforceDistribution` will add `RepartitionExec` as needed. Only the interleave optimization is lost. ## Are these changes tested? Yes, two unit tests added: - `test_interleave_fallback_to_union_on_partitioning_mismatch` — verifies fallback to UnionExec when one child's partitioning changes from Hash to RoundRobin - `test_interleave_preserved_when_partitioning_matches` — verifies InterleaveExec is preserved when children's Hash partitioning remains consistent -- 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]
