924060929 commented on code in PR #11673: URL: https://github.com/apache/doris/pull/11673#discussion_r943198726
########## fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java: ########## @@ -286,10 +288,42 @@ public PlanFragment visitLogicalSort(LogicalSort<Plan> sort, PlanTranslatorConte } @Override - public PlanFragment visitPhysicalHeapSort(PhysicalHeapSort<Plan> sort, + public PlanFragment visitPhysicalQuickSort(PhysicalQuickSort<Plan> sort, PlanTranslatorContext context) { + PlanFragment childFragment = visitAbstractPhysicalSort(sort, context); + SortNode sortNode = (SortNode) childFragment.getPlanRoot(); + //isPartitioned()==true means there is only one instance, so no merge phase Review Comment: isPartitioned() == false ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/PlanVisitor.java: ########## @@ -130,10 +137,18 @@ public R visitPhysicalOlapScan(PhysicalOlapScan olapScan, C context) { return visitPhysicalScan(olapScan, context); } - public R visitPhysicalHeapSort(PhysicalHeapSort<Plan> sort, C context) { + public R visitAbstractPhysicalSort(AbstractPhysicalSort<Plan> sort, C context) { return visit(sort, context); } + public R visitPhysicalQuickSort(PhysicalQuickSort<Plan> sort, C context) { + return visit(sort, context); Review Comment: ```suggestion return visitAbstractPhysicalSort(sort, context); ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java: ########## @@ -286,10 +288,42 @@ public PlanFragment visitLogicalSort(LogicalSort<Plan> sort, PlanTranslatorConte } @Override - public PlanFragment visitPhysicalHeapSort(PhysicalHeapSort<Plan> sort, + public PlanFragment visitPhysicalQuickSort(PhysicalQuickSort<Plan> sort, PlanTranslatorContext context) { + PlanFragment childFragment = visitAbstractPhysicalSort(sort, context); + SortNode sortNode = (SortNode) childFragment.getPlanRoot(); + //isPartitioned()==true means there is only one instance, so no merge phase + if (!childFragment.isPartitioned()) { + return childFragment; + } + PlanFragment mergeFragment = createParentFragment(childFragment, DataPartition.UNPARTITIONED, context); + ExchangeNode exchangeNode = (ExchangeNode) mergeFragment.getPlanRoot(); + //exchangeNode.limit/offset will be set in when translating PhysicalLimit + exchangeNode.setMergeInfo(sortNode.getSortInfo()); + return mergeFragment; + } + + @Override + public PlanFragment visitPhysicalTopN(PhysicalTopN<Plan> topN, PlanTranslatorContext context) { + PlanFragment childFragment = visitAbstractPhysicalSort(topN, context); + SortNode sortNode = (SortNode) childFragment.getPlanRoot(); + sortNode.setOffset(topN.getOffset()); + sortNode.setLimit(topN.getLimit()); + //isPartitioned()==true means there is only one instance, so no merge phase Review Comment: ditto -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org