wiedld opened a new pull request, #14637: URL: https://github.com/apache/datafusion/pull/14637
## Which issue does this PR close? I'll make a new issue, once we confirm this reproducer is a bug. ## Rationale for this change We have physical plans which are failing in the sanity checker. Taking the plan as it is when provided to the `EnforceSorting`, it is a valid plan (defined "valid" as passing the sanity check). After the `EnforceSorting`, it fails due to the removal of the needed coalesce. I've added a temporary patch to our forked datafusion which adds to [this conditional](https://github.com/apache/datafusion/blob/2d303346c7d44a78d317e7b7b959cbd94edfb891/datafusion/physical-optimizer/src/enforce_sorting/mod.rs#L526), in order to prevent the removal of the coalesce. However, I'm unclear whether an actual fix should be the replacement of the coalesce with an SPM _at the correct location_ (instead of placing the SPM after the aggregate, which no longer fulfills the distribution requirements). ## What changes are included in this PR? Demonstrate the bug. ## Are these changes tested? ## Are there any user-facing changes? -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org