wangyum commented on code in PR #37104:
URL: https://github.com/apache/spark/pull/37104#discussion_r922950112
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -130,8 +130,24 @@ abstract class SparkStrategies extends
QueryPlanner[SparkPlan] {
if limit < conf.topKSortFallbackThreshold =>
Some(TakeOrderedAndProjectExec(
limit, order, projectList, planLater(child)))
+ case Sort(order, true, child) if supportTakeOrdered(child) =>
+ Some(TakeOrderedAndProjectExec(
+ child.maxRows.get.toInt, order, child.output, planLater(child)))
+ case Project(projectList, Sort(order, true, child)) if
supportTakeOrdered(child) =>
+ Some(TakeOrderedAndProjectExec(
+ child.maxRows.get.toInt, order, projectList, planLater(child)))
case _ => None
}
+
+ private def supportTakeOrdered(plan: LogicalPlan): Boolean = {
+ // Maximum support up to 655360, a larger number of rows does not
improve performance.
+ plan.maxRows.exists(_ < math.min(conf.topKSortFallbackThreshold,
655360)) &&
Review Comment:
OK. new config: `spark.sql.execution.topKSortMaxRowsThreshold`.
--
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]