This is an automated email from the ASF dual-hosted git repository.
starocean999 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 1a4929b59e [fix](planner) having clause analyze bug #24288
1a4929b59e is described below
commit 1a4929b59eb7b4a96b9256eafbe1f4e0fe3a1625
Author: minghong <[email protected]>
AuthorDate: Thu Sep 14 09:54:09 2023 +0800
[fix](planner) having clause analyze bug #24288
---
.../java/org/apache/doris/analysis/SelectStmt.java | 6 ++-
.../suites/query_p0/having/having.groovy | 49 ++++++++++++++++++++++
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 0f03afde0a..67c2a06a1c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -1811,10 +1811,12 @@ public class SelectStmt extends QueryStmt {
whereClause.collect(Subquery.class, subqueryExprs);
}
- if (havingClause != null) {
- havingClause = rewriter.rewrite(havingClause, analyzer);
+
+ if (havingClauseAfterAnalyzed != null) {
+ havingClauseAfterAnalyzed =
rewriter.rewrite(havingClauseAfterAnalyzed, analyzer);
havingClauseAfterAnalyzed.collect(Subquery.class, subqueryExprs);
}
+
for (Subquery subquery : subqueryExprs) {
subquery.getStatement().rewriteExprs(rewriter);
}
diff --git a/regression-test/suites/query_p0/having/having.groovy
b/regression-test/suites/query_p0/having/having.groovy
new file mode 100644
index 0000000000..2cb0755d54
--- /dev/null
+++ b/regression-test/suites/query_p0/having/having.groovy
@@ -0,0 +1,49 @@
+// 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.
+
+// The cases is copied from https://github.com/trinodb/trino/tree/master
+//
/testing/trino-product-tests/src/main/resources/sql-tests/testcases/aggregate
+// and modified by Doris.
+
+suite("having") {
+ sql "set enable_nereids_planner=false;"
+ sql """CREATE TABLE `supplier` (
+ `s_suppkey` int(11) NOT NULL,
+ `s_name` varchar(25) NOT NULL,
+ `s_address` varchar(40) NOT NULL,
+ `s_nationkey` int(11) NOT NULL,
+ `s_phone` varchar(15) NOT NULL,
+ `s_acctbal` DECIMAL(15, 2) NOT NULL,
+ `s_comment` varchar(101) NOT NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`s_suppkey`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 12
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "is_being_synced" = "false",
+ "storage_format" = "V2",
+ "light_schema_change" = "true",
+ "disable_auto_compaction" = "false",
+ "enable_single_replica_compaction" = "false"
+ ); """
+ sql """explain
+ select count(*)
+ from supplier s
+ group by s_nationkey,s_suppkey
+ having s_nationkey=1 or s_suppkey=1;"""
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]