You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/10/15 03:07:42 UTC
[doris] branch master updated: [fix](agg) reset the content of grouping exprs instead of replace it with original exprs (#13376)
This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 bf2e20c4c4 [fix](agg) reset the content of grouping exprs instead of replace it with original exprs (#13376)
bf2e20c4c4 is described below
commit bf2e20c4c4db076d4988c24bf4df9bd16831a52a
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Sat Oct 15 11:07:35 2022 +0800
[fix](agg) reset the content of grouping exprs instead of replace it with original exprs (#13376)
* [fix](agg)the reseet the content of grouping exprs instead of replace it with original exprs
* keep old behavior if the grouping type is not GROUP_BY
---
.../org/apache/doris/analysis/GroupByClause.java | 16 ++++--
.../data/correctness_p0/test_group_by_constant.out | 4 ++
.../correctness_p0/test_group_by_constant.groovy | 63 ++++++++++++++++++++++
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java
index 7e66ae85fa..08010dbec0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java
@@ -93,12 +93,20 @@ public class GroupByClause implements ParseNode {
}
public void reset() {
- groupingExprs = new ArrayList<>();
analyzed = false;
exprGenerated = false;
- if (oriGroupingExprs != null) {
- Expr.resetList(oriGroupingExprs);
- groupingExprs.addAll(oriGroupingExprs);
+ if (groupingType != GroupingType.GROUP_BY) {
+ groupingExprs = new ArrayList<>();
+ if (oriGroupingExprs != null) {
+ Expr.resetList(oriGroupingExprs);
+ groupingExprs.addAll(oriGroupingExprs);
+ }
+ } else {
+ if (groupingExprs != null) {
+ for (Expr e : groupingExprs) {
+ e.reset();
+ }
+ }
}
if (groupingSetList != null) {
for (List<Expr> s : groupingSetList) {
diff --git a/regression-test/data/correctness_p0/test_group_by_constant.out b/regression-test/data/correctness_p0/test_group_by_constant.out
new file mode 100644
index 0000000000..64fb35ea90
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_group_by_constant.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+D
+
diff --git a/regression-test/suites/correctness_p0/test_group_by_constant.groovy b/regression-test/suites/correctness_p0/test_group_by_constant.groovy
new file mode 100644
index 0000000000..8f332b2210
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_group_by_constant.groovy
@@ -0,0 +1,63 @@
+// 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_group_by_constant") {
+
+ sql """
+ DROP TABLE IF EXISTS `table_group_by_constant`;
+ """
+
+ sql """
+ CREATE TABLE `table_group_by_constant` (
+ `inc_day` date NULL
+ ) ENGINE=OLAP
+ UNIQUE KEY(`inc_day`)
+ DISTRIBUTED BY HASH(`inc_day`) BUCKETS 5
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ );
+ """
+
+ sql """
+ insert into table_group_by_constant values('1999-12-01');
+ """
+
+ qt_sql """
+ SELECT
+ case
+ when (inc_day = date_sub(curdate(), interval 1 day)) then 'A'
+ when (inc_day = date_sub(curdate(), interval 8 day)) then 'B'
+ when (inc_day = date_sub(curdate(), interval 365 day)) then 'C'
+ else 'D'
+ end
+ from
+ table_group_by_constant
+ group by
+ case
+ when (inc_day = date_sub(curdate(), interval 1 day)) then 'A'
+ when (inc_day = date_sub(curdate(), interval 8 day)) then 'B'
+ when (inc_day = date_sub(curdate(), interval 365 day)) then 'C'
+ else 'D'
+ end;
+ """
+
+ sql """
+ DROP TABLE IF EXISTS `table_group_by_constant`;
+ """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org