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 894f38a517 [fix](planner) fix conjunct planned on exchange node
(#18042)
894f38a517 is described below
commit 894f38a517b69deeef8140f2a35525013628959a
Author: mch_ucchi <[email protected]>
AuthorDate: Mon Mar 27 17:50:52 2023 +0800
[fix](planner) fix conjunct planned on exchange node (#18042)
sql like:
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
group by k5, k6
) AS temp where 1=1
group by k5, k6;
will throw exception since conjuncts planned on exchange node, because
exchange node cannot handle conjuncts, now we skip exchange node when planning
conjuncts, which fixes the bug.
notice: the bug occurs iff the conjunct is always true like 1=1 above.
---
.../java/org/apache/doris/planner/PlanNode.java | 4 ++
.../suites/correctness_p0/test_distinct_agg.groovy | 58 ++++++++++++++++++++++
2 files changed, 62 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 0b10c3afe2..3d6ad9f57b 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
@@ -719,6 +719,10 @@ public abstract class PlanNode extends TreeNode<PlanNode>
implements PlanStats {
* 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;
+ }
List<Expr> unassigned = analyzer.getUnassignedConjuncts(this);
for (Expr unassignedConjunct : unassigned) {
addConjunct(unassignedConjunct);
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 0000000000..8c80c9f184
--- /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 `t` (`k1`, `k2`, `k3`, `k4`, `k5`, `k6`) 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([['1', '2023-01-10', 1L]])
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]