diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java index acb3ebe87b..5d78760c9a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java @@ -1602,13 +1602,21 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor limit, PlanContext context) { Preconditions.checkState(childrenOutputProperties.size() == 1); PhysicalProperties childOutputProperty = childrenOutputProperties.get(0); + if (limit.getPhase().isLocal()) { + return new PhysicalProperties(childOutputProperty.getDistributionSpec(), + childOutputProperty.getOrderSpec()); + } return new PhysicalProperties(DistributionSpecGather.INSTANCE, childOutputProperty.getOrderSpec()); } diff --git a/regression-test/suites/nereids_p0/limit/sql/useRestrictiveLimitFromSubq.sql b/regression-test/suites/nereids_p0/limit/sql/useRestrictiveLimitFromSubq.sql index c7a1a6659a..b9db067d77 100644 --- a/regression-test/suites/nereids_p0/limit/sql/useRestrictiveLimitFromSubq.sql +++ b/regression-test/suites/nereids_p0/limit/sql/useRestrictiveLimitFromSubq.sql @@ -1,2 +1,3 @@ -- database: presto; groups: limit; tables: nation -SELECT COUNT(*) FROM (SELECT * FROM tpch_tiny_nation LIMIT 2) AS foo LIMIT 5 +SELECT /*+SET_VAR(parallel_fragment_exec_instance_num=2) */ +COUNT(*) FROM (SELECT * FROM tpch_tiny_nation LIMIT 2) AS foo LIMIT 5 diff --git a/regression-test/suites/nereids_p0/limit/sql/withGroupByInSubq.sql b/regression-test/suites/nereids_p0/limit/sql/withGroupByInSubq.sql index dc01b0ca92..0b53dc0cab 100644 --- a/regression-test/suites/nereids_p0/limit/sql/withGroupByInSubq.sql +++ b/regression-test/suites/nereids_p0/limit/sql/withGroupByInSubq.sql @@ -1,4 +1,5 @@ -- database: presto; groups: limit; tables: partsupp -SELECT COUNT(*) FROM ( +SELECT /*+SET_VAR(parallel_fragment_exec_instance_num=2) */ +COUNT(*) FROM ( SELECT suppkey, COUNT(*) FROM tpch_tiny_partsupp GROUP BY suppkey LIMIT 20) t1 diff --git a/regression-test/suites/nereids_p0/limit/sql/withJoinInSubq.sql b/regression-test/suites/nereids_p0/limit/sql/withJoinInSubq.sql index 2abb6d48ef..444bccf623 100644 --- a/regression-test/suites/nereids_p0/limit/sql/withJoinInSubq.sql +++ b/regression-test/suites/nereids_p0/limit/sql/withJoinInSubq.sql @@ -1 +1,2 @@ -SELECT COUNT(*) FROM (SELECT n1.regionkey, n1.nationkey FROM tpch_tiny_nation n1 JOIN tpch_tiny_nation n2 ON n1.regionkey = n2.regionkey LIMIT 5) foo +SELECT /*+SET_VAR(parallel_fragment_exec_instance_num=2) */ +COUNT(*) FROM (SELECT n1.regionkey, n1.nationkey FROM tpch_tiny_nation n1 JOIN tpch_tiny_nation n2 ON n1.regionkey = n2.regionkey LIMIT 5) foo diff --git a/regression-test/suites/nereids_p0/limit/sql/withSubq.sql b/regression-test/suites/nereids_p0/limit/sql/withSubq.sql index ebb14262df..3cc941a518 100644 --- a/regression-test/suites/nereids_p0/limit/sql/withSubq.sql +++ b/regression-test/suites/nereids_p0/limit/sql/withSubq.sql @@ -1,2 +1,3 @@ -- database: presto; groups: limit; tables: nation -SELECT COUNT(*) FROM (SELECT * FROM tpch_tiny_nation LIMIT 10) t1 +SELECT /*+SET_VAR(parallel_fragment_exec_instance_num=2) */ +COUNT(*) FROM (SELECT * FROM tpch_tiny_nation LIMIT 10) t1