iSparshP opened a new pull request, #2998: URL: https://github.com/apache/datafusion-ballista/pull/2998
# Which issue does this PR close? Closes #2951. # Rationale for this change with the adaptive planner a hash ExchangeExec kept its input's ordering, and the reader merged the shuffle files on it. a sort shuffle partition holds one sorted run per input partition back to back, so the merge gives rows out of order but still claims [c2, c9, rn]. SortExec passes its input through when the input already claims the order, so the SortExec(c2) under the count window did nothing and each c2 got split up. # What changes are included in this PR? - ExchangeExec clears its orderings when it has a partitioning, same as RepartitionExec without preserve_order (it already said maintains_input_order = false) - the adapter only plants RangeShuffleReaderExec when the exchange keeps its input partitions, so hash exchanges get the plain ShuffleReaderExec - when DistributedExchangeRule or PinSubmittedShufflesRule replace a hash RepartitionExec that has preserve_order=true (you get those with prefer_existing_sort), they now put a SortExec on top of the exchange. without that the exchange claims no order, nothing above sorts, and the replan fails datafusion's sanity check so the job just hangs - the issue's query as a test against datafusion, for both planners plus adaptive with prefer_existing_sort, and unit tests in adapter.rs i needed the first two together: with only the first one the sort stays but the merge reader still claims the order, with only the second one the replan drops the sort and the window asserts. this is fix 1 from my comment on the issue. the other option is fix 2: keep the merge based read and change the sort shuffle file layout so each input run stays separate. that keeps the order across the shuffle but touches the writer and the file format. @NoahKusaba which one do you prefer? happy to switch. two things i found along the way that i left out: - the static planner has the same preserve_order problem. with prefer_existing_sort on, planner.rs turns the order preserving hash repartition into a plain shuffle and the window asserts "All partition by columns should have an ordering". same fix would work there, i can do it here or in a follow up. - #2952 isn't the same cause after all. in the LEFT JOIN query the ORDER BY requirement is already gone in the first plan (order_by=[] at the root, the topk under the single partition join covered it), and when the join gets repartitioned nothing puts the sort back. the UNION BY NAME one passes for me with and without this change at 4 partitions. so i'll leave #2952 for a separate pr. # Are there any user-facing changes? no, just correct results for window queries over a hash shuffle with the adaptive planner, and no more hang when prefer_existing_sort is on. -- 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]
