xudong963 commented on code in PR #15822: URL: https://github.com/apache/datafusion/pull/15822#discussion_r2057547218
########## datafusion/physical-optimizer/src/enforce_sorting/replace_with_order_preserving_variants.rs: ########## @@ -137,6 +137,12 @@ fn plan_with_order_preserving_variants( return Ok(sort_input); } else if is_coalesce_partitions(&sort_input.plan) && is_spm_better { let child = &sort_input.children[0].plan; + let mut fetch = fetch; + // Also need to check if the coalesce node has a fetch + if let Some(coalesce_fetch) = sort_input.plan.fetch() { + // Get the min fetch between the `fetch` and the coalesce's fetch: + fetch = Some(coalesce_fetch.min(fetch.unwrap_or(usize::MAX))) Review Comment: That's fair, let's return an error -- 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