This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 8208ced21df67dd624c1e9751df05c0c2d46f58e
Author: starocean999 <[email protected]>
AuthorDate: Fri May 26 11:05:02 2023 +0800

    [fix](planner) The group by part should be substituted in the same way as 
select part (#20019)
---
 .../java/org/apache/doris/analysis/SelectStmt.java |  2 ++
 .../correctness_p0/test_grouping_with_alias.out    |  3 +++
 .../correctness_p0/test_grouping_with_alias.groovy | 23 ++++++++++++++++++++++
 3 files changed, 28 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 9e36a5a51a..7fe993ae9a 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
@@ -1178,6 +1178,8 @@ public class SelectStmt extends QueryStmt {
                 aliasFirst = 
analyzer.getContext().getSessionVariable().isGroupByAndHavingUseAliasFirst();
             }
             substituteOrdinalsAliases(groupingExprs, "GROUP BY", analyzer, 
aliasFirst);
+            // the groupingExprs must substitute in the same way as resultExprs
+            groupingExprs = Expr.substituteList(groupingExprs, countAllMap, 
analyzer, false);
 
             if (!groupByClause.isGroupByExtension() && 
!groupingExprs.isEmpty()) {
                 /*
diff --git a/regression-test/data/correctness_p0/test_grouping_with_alias.out 
b/regression-test/data/correctness_p0/test_grouping_with_alias.out
index d2cd147634..850b4daf7b 100644
--- a/regression-test/data/correctness_p0/test_grouping_with_alias.out
+++ b/regression-test/data/correctness_p0/test_grouping_with_alias.out
@@ -4,3 +4,6 @@ a       1
 all    1
 all    2
 
+-- !select2 --
+1.0    1
+
diff --git 
a/regression-test/suites/correctness_p0/test_grouping_with_alias.groovy 
b/regression-test/suites/correctness_p0/test_grouping_with_alias.groovy
index 4b6a29fe43..26f6c5eeab 100644
--- a/regression-test/suites/correctness_p0/test_grouping_with_alias.groovy
+++ b/regression-test/suites/correctness_p0/test_grouping_with_alias.groovy
@@ -34,4 +34,27 @@
         col1,
         cnt;
      """
+
+    sql """DROP TABLE IF EXISTS `cf_member`; """
+    sql """ 
+        CREATE TABLE `cf_member` (
+        `id` bigint(20) NOT NULL,
+        `userinfoid` bigint(20) NULL,
+        `username` text NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`id`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`id`) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "in_memory" = "false",
+        "storage_format" = "V2",
+        "disable_auto_compaction" = "false"
+        );
+    """
+    sql """insert into cf_member values(2, 2, '2'); """
+
+    qt_select2 """select floor(id-1.0), count(*) from cf_member cm group by 
floor(id-1.0);"""
+
+    sql """DROP TABLE IF EXISTS `cf_member`; """
  } 
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to