This is an automated email from the ASF dual-hosted git repository.
kxiao 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 7c597ed9e6a [fix](legacy-planner) fixed loss of BetweenPredicate
rewrite on reanalyze in legacy planner (29798) (#30328)
7c597ed9e6a is described below
commit 7c597ed9e6af575e3571be07ec0f24f47667c441
Author: Nitin-Kashyap <[email protected]>
AuthorDate: Sat Feb 3 13:58:03 2024 +0530
[fix](legacy-planner) fixed loss of BetweenPredicate rewrite on reanalyze
in legacy planner (29798) (#30328)
---
.../java/org/apache/doris/analysis/SelectStmt.java | 1 +
.../data/query_p0/having/having_between.out | 31 ++++++++++
.../suites/query_p0/having/having_between.groovy | 72 ++++++++++++++++++++++
3 files changed, 104 insertions(+)
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 d316a07f093..bd7da27a67a 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
@@ -1890,6 +1890,7 @@ public class SelectStmt extends QueryStmt {
if (havingClauseAfterAnalyzed != null) {
havingClauseAfterAnalyzed =
rewriter.rewrite(havingClauseAfterAnalyzed, analyzer);
havingClauseAfterAnalyzed.collect(Subquery.class, subqueryExprs);
+ havingClause = havingClauseAfterAnalyzed.clone();
}
for (Subquery subquery : subqueryExprs) {
diff --git a/regression-test/data/query_p0/having/having_between.out
b/regression-test/data/query_p0/having/having_between.out
new file mode 100644
index 00000000000..d8adf194fd7
--- /dev/null
+++ b/regression-test/data/query_p0/having/having_between.out
@@ -0,0 +1,31 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql01 --
+aa ba 22 cc 11 \N
+b b 242 c 121 \N
+bb b 22 c 11 \N
+
+-- !sql02 --
+aa 1
+b 1
+bb 1
+
+-- !sql03 --
+aa 1
+b 1
+bb 1
+
+-- !sql01 --
+aa ba 22 cc 11 \N
+b b 242 c 121 \N
+bb b 22 c 11 \N
+
+-- !sql02 --
+aa 1
+b 1
+bb 1
+
+-- !sql03 --
+aa 1
+b 1
+bb 1
+
diff --git a/regression-test/suites/query_p0/having/having_between.groovy
b/regression-test/suites/query_p0/having/having_between.groovy
new file mode 100644
index 00000000000..9b7e89ad6ae
--- /dev/null
+++ b/regression-test/suites/query_p0/having/having_between.groovy
@@ -0,0 +1,72 @@
+// 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_having_between", "query,p0") {
+ def DBname = "test_having_between"
+ def tableName = "tbl_having_between"
+ sql "DROP DATABASE IF EXISTS ${DBname}"
+ sql "CREATE DATABASE IF NOT EXISTS ${DBname}"
+ sql "use ${DBname}"
+
+ sql "DROP TABLE IF EXISTS ${tableName};"
+
+ sql """
+ CREATE TABLE ${tableName}(a DATE, b VARCHAR(100), c VARCHAR(100), d
VARCHAR(100), e INT, f INT)
+ ENGINE=OLAP
+ DUPLICATE KEY( a )
+ COMMENT "OLAP"
+ DISTRIBUTED BY HASH( e ) BUCKETS auto
+ PROPERTIES (
+ "replication_num" = "1"
+ );
+ """
+
+ def test_query = {
+ qt_sql01 """
+ select t1.b,t1.c,t1.f,t1.d,t1.e,stddev_pop(t1.d+t1.e) std from
${tableName} t1
+ group by t1.f,t1.d,t1.e,t1.a,t1.b,t1.c
+ having t1.b between 'aa' and 'bb' order by 1;
+ """
+
+ qt_sql02 """
+ SELECT b, count(*) FROM ${tableName} GROUP BY 1 HAVING b BETWEEN
'aa' AND 'bb' order by 1;
+ """
+
+ qt_sql03 """
+ SELECT b, count(*) FROM ${tableName} GROUP BY 1 HAVING b >= 'aa'
AND b <= 'bb' order by 1;
+ """
+ }
+
+ sql "INSERT INTO ${tableName} VALUES(now(), 'a', 'b', 'c', 11, 22);"
+ sql "INSERT INTO ${tableName} VALUES(now(), 'aa', 'ba', 'cc', 11, 22);"
+ sql "INSERT INTO ${tableName} VALUES(now(), 'b', 'b', 'c', 121, 242);"
+ sql "INSERT INTO ${tableName} VALUES(now(), 'bb', 'b', 'c', 11, 22);"
+ sql "INSERT INTO ${tableName} VALUES(now(), 'bbb', 'b', 'c', 11, 22);"
+
+ sql """set enable_nereids_planner=true;"""
+ sql "set enable_fallback_to_original_planner=false;"
+
+ // with nereids planner
+ test_query()
+ sql """set enable_nereids_planner=false;"""
+
+ // with legacy planner
+ test_query()
+
+ sql "DROP TABLE ${tableName};"
+ sql "DROP DATABASE ${DBname};"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]