From 284ee59cb3a22b20af6d8cc0eab3bce964dfcada Mon Sep 17 00:00:00 2001 From: sohardforaname Date: Thu, 23 Mar 2023 11:48:28 +0800 Subject: [PATCH 1/4] 'fix-bugs' --- .../src/main/java/org/apache/doris/planner/PlanNode.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java index fd66e7e1a34c9b..cc3bbd4178e7fc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java @@ -717,6 +717,9 @@ public void init(Analyzer analyzer) throws UserException { * Assign remaining unassigned conjuncts. */ protected void assignConjuncts(Analyzer analyzer) { + if (this instanceof ExchangeNode) { + return; + } List unassigned = analyzer.getUnassignedConjuncts(this); for (Expr unassignedConjunct : unassigned) { addConjunct(unassignedConjunct); From 8476e860fb2a2ff33b4aa8a860ca5fa4c1519d28 Mon Sep 17 00:00:00 2001 From: sohardforaname Date: Thu, 23 Mar 2023 13:14:44 +0800 Subject: [PATCH 2/4] 'fix-bugs' --- .../org/apache/doris/planner/PlanNode.java | 1 + .../correctness_p0/test_distinct_agg.groovy | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 regression-test/suites/correctness_p0/test_distinct_agg.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java index cc3bbd4178e7fc..6e1a4fcfb85fbf 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java @@ -717,6 +717,7 @@ public void init(Analyzer analyzer) throws UserException { * Assign remaining unassigned conjuncts. */ protected void assignConjuncts(Analyzer analyzer) { + // we cannot plan conjuncts on exchange node, so we just skip the node. if (this instanceof ExchangeNode) { return; } diff --git a/regression-test/suites/correctness_p0/test_distinct_agg.groovy b/regression-test/suites/correctness_p0/test_distinct_agg.groovy new file mode 100644 index 00000000000000..2c4150b6378782 --- /dev/null +++ b/regression-test/suites/correctness_p0/test_distinct_agg.groovy @@ -0,0 +1,58 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_distinct_agg") { + sql 'drop table if exists t' + + sql ''' + CREATE TABLE `t` ( + `k1` bigint(20) NULL, + `k2` varchar(20) NULL, + `k3` varchar(20) NULL, + `k4` varchar(20) NULL, + `k5` varchar(20) NULL, + `k6` datetime NULL + ) ENGINE=OLAP + UNIQUE KEY(`k1`, `k2`) + DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 3 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + ); + ''' + + sql ''' + INSERT INTO `dws_task_campaign_wide` (`id`, `shard_key`, `user_id`, `customer_id`, `popu_cust_channel`, `trans_time`) + VALUES (1, '1234', 'A0', 'C0', '1', '2023-01-10 23:00:00'); + ''' + + test { + sql ''' + select k5, k6, SUM(k3) AS k3 + from ( + select + k5, + date_format(k6, '%Y-%m-%d') as k6, + count(distinct k3) as k3 + from t + where 1=1 + group by k5, k6 + ) AS temp where 1=1 + group by k5, k6; + ''' + result([[1L, '2013-01-10', 1L]]) + } +} \ No newline at end of file From f0f055ed8b7fc80d77532425d0b764a9a12b9a8a Mon Sep 17 00:00:00 2001 From: sohardforaname Date: Thu, 23 Mar 2023 13:17:12 +0800 Subject: [PATCH 3/4] 'fix-bugs' --- .../suites/correctness_p0/test_distinct_agg.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/regression-test/suites/correctness_p0/test_distinct_agg.groovy b/regression-test/suites/correctness_p0/test_distinct_agg.groovy index 2c4150b6378782..bd01005d76868d 100644 --- a/regression-test/suites/correctness_p0/test_distinct_agg.groovy +++ b/regression-test/suites/correctness_p0/test_distinct_agg.groovy @@ -30,12 +30,12 @@ suite("test_distinct_agg") { UNIQUE KEY(`k1`, `k2`) DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 3 PROPERTIES ( - "replication_allocation" = "tag.location.default: 1", - ); + "replication_allocation" = "tag.location.default: 1" + ); ''' sql ''' - INSERT INTO `dws_task_campaign_wide` (`id`, `shard_key`, `user_id`, `customer_id`, `popu_cust_channel`, `trans_time`) + INSERT INTO `t` (`k1`, `k2`, `k3`, `k4`, `k5`, `k6`) VALUES (1, '1234', 'A0', 'C0', '1', '2023-01-10 23:00:00'); ''' From 27714ad1c5db5a719fa89ac059c4f32484d75b1c Mon Sep 17 00:00:00 2001 From: sohardforaname Date: Thu, 23 Mar 2023 14:03:27 +0800 Subject: [PATCH 4/4] 'fix-bugs' --- .../suites/correctness_p0/test_distinct_agg.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/regression-test/suites/correctness_p0/test_distinct_agg.groovy b/regression-test/suites/correctness_p0/test_distinct_agg.groovy index bd01005d76868d..8c80c9f1847a38 100644 --- a/regression-test/suites/correctness_p0/test_distinct_agg.groovy +++ b/regression-test/suites/correctness_p0/test_distinct_agg.groovy @@ -35,8 +35,8 @@ suite("test_distinct_agg") { ''' sql ''' - INSERT INTO `t` (`k1`, `k2`, `k3`, `k4`, `k5`, `k6`) - VALUES (1, '1234', 'A0', 'C0', '1', '2023-01-10 23:00:00'); + INSERT INTO `t` (`k1`, `k2`, `k3`, `k4`, `k5`, `k6`) VALUES + (1, '1234', 'A0', 'C0', '1', '2023-01-10 23:00:00'); ''' test { @@ -53,6 +53,6 @@ suite("test_distinct_agg") { ) AS temp where 1=1 group by k5, k6; ''' - result([[1L, '2013-01-10', 1L]]) + result([['1', '2023-01-10', 1L]]) } } \ No newline at end of file