apapi edited a comment on issue #27077: [SPARK-30408][SQL] Should not remove orderBy in sortBy clause in Optimizer URL: https://github.com/apache/spark/pull/27077#issuecomment-571900240 @maropu My example in description is ambiguous, I updated the example. More details: For ```val sortData = dataset.orderBy("b").sortWithinPartitions("c")``` In Analyzed Logical Plan of sortData, there are 2 Sorts, the first is is a local sort, which is the result of ```sortWithinPartitions("c")```. The second is a global sort, which is the result of ```orderBy("b")```. But in the Optimized Logical plan, there is only one Sort, it is the first local sort, which is the result of ```sortWithinPartitions("c")```. The global sort (which is the result of ```orderBy("b")```) was removed by the Optimizer. In the code ```dataset``` was first repartitioned by ```orderBy()```, then content within each partition sorted by ```sortWithinPartitions()```. ```orderBy()``` may lead to repartition, but ```sortWithinPartitions()``` will not. So remove global sort lead to the lost of the repartition operation, which is not correct.
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
