You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/10/25 08:55:35 UTC
[doris] branch master updated: [fix](Nereids) add exchange node check between local and global agg in plan translator (#12913)
This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new f209b7ab6e [fix](Nereids) add exchange node check between local and global agg in plan translator (#12913)
f209b7ab6e is described below
commit f209b7ab6e22ba85a9e12b6affdfa08a6bff5a70
Author: yinzhijian <37...@qq.com>
AuthorDate: Tue Oct 25 16:55:29 2022 +0800
[fix](Nereids) add exchange node check between local and global agg in plan translator (#12913)
### table schema
CREATE TABLE `t1` (
`k1` int(11) NULL,
`v1` int(11) NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`, `v1`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`k1`)
BUCKETS 3
PROPERTIES('replication_num'='1')
### query
select k1,count(distinct v1+1) from t1 group by k1;
### error
java.lang.ClassCastException: org.apache.doris.planner.OlapScanNode cannot be cast to org.apache.doris.planner.AggregationNode
---
.../doris/nereids/glue/translator/PhysicalPlanTranslator.java | 8 +++++++-
regression-test/data/nereids_syntax_p0/function.out | 5 +++++
regression-test/suites/nereids_syntax_p0/function.groovy | 4 ++++
3 files changed, 16 insertions(+), 1 deletion(-)
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 1b973daf47..8fc0ba7f92 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
@@ -201,7 +201,13 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
outputTupleDesc = generateTupleDesc(slotList, null, context);
} else {
// In the distinct agg scenario, global shares local's desc
- AggregationNode localAggNode = (AggregationNode) inputPlanFragment.getPlanRoot().getChild(0);
+ AggregationNode localAggNode;
+ if (inputPlanFragment.getPlanRoot() instanceof ExchangeNode) {
+ localAggNode = (AggregationNode) inputPlanFragment.getPlanRoot().getChild(0);
+ } else {
+ // If the group by expr hits the partition key, there may be no exchange node
+ localAggNode = (AggregationNode) inputPlanFragment.getPlanRoot();
+ }
outputTupleDesc = localAggNode.getAggInfo().getOutputTupleDesc();
}
diff --git a/regression-test/data/nereids_syntax_p0/function.out b/regression-test/data/nereids_syntax_p0/function.out
index f8b8fef592..844816f3dd 100644
--- a/regression-test/data/nereids_syntax_p0/function.out
+++ b/regression-test/data/nereids_syntax_p0/function.out
@@ -16,6 +16,11 @@
1
1
+-- !distinct_count_group_by_distributed_key --
+1303 1
+1309 1
+1312 1
+
-- !avg --
5.0 2356811.0
diff --git a/regression-test/suites/nereids_syntax_p0/function.groovy b/regression-test/suites/nereids_syntax_p0/function.groovy
index a041fc36ab..1ad34fdedf 100644
--- a/regression-test/suites/nereids_syntax_p0/function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/function.groovy
@@ -45,6 +45,10 @@ suite("function") {
SELECT count(distinct c_custkey + 1) AS custdist FROM customer group by c_city;
"""
+ order_qt_distinct_count_group_by_distributed_key """
+ SELECT c_custkey, count(distinct c_custkey + 1) AS custdist FROM customer group by c_custkey;
+ """
+
order_qt_avg """
SELECT avg(lo_tax), avg(lo_extendedprice) AS avg_extendedprice FROM lineorder;
"""
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org