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 4ba2422039 [improvement](fe) Remove constant keys in aggregation
(#11434)
4ba2422039 is described below
commit 4ba2422039170b75f1082ad29c92a97e100b7b6d
Author: Jerry Hu <[email protected]>
AuthorDate: Wed Aug 3 19:43:35 2022 +0800
[improvement](fe) Remove constant keys in aggregation (#11434)
---
.../java/org/apache/doris/analysis/SelectStmt.java | 15 ++++++++++----
regression-test/data/query/aggregate/aggregate.out | 23 ++++++++++++++++++++++
.../suites/query/aggregate/aggregate.groovy | 2 ++
3 files changed, 36 insertions(+), 4 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 b087ff451b..2440dc1956 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
@@ -1048,17 +1048,24 @@ public class SelectStmt extends QueryStmt {
List<TupleId> groupingByTupleIds = new ArrayList<>();
if (groupByClause != null) {
groupByClause.genGroupingExprs();
+ ArrayList<Expr> groupingExprs = groupByClause.getGroupingExprs();
if (groupingInfo != null) {
- groupingInfo.buildRepeat(groupByClause.getGroupingExprs(),
groupByClause.getGroupingSetList());
+ groupingInfo.buildRepeat(groupingExprs,
groupByClause.getGroupingSetList());
}
- substituteOrdinalsAliases(groupByClause.getGroupingExprs(), "GROUP
BY", analyzer);
+
+ substituteOrdinalsAliases(groupingExprs, "GROUP BY", analyzer);
+
+ if (!groupByClause.isGroupByExtension()) {
+ groupingExprs.removeIf(Expr::isConstant);
+ }
+
if (groupingInfo != null) {
- groupingInfo.genOutputTupleDescAndSMap(analyzer,
groupByClause.getGroupingExprs(), aggExprs);
+ groupingInfo.genOutputTupleDescAndSMap(analyzer,
groupingExprs, aggExprs);
// must do it before copying for createAggInfo()
groupingByTupleIds.add(groupingInfo.getOutputTupleDesc().getId());
}
groupByClause.analyze(analyzer);
- createAggInfo(groupByClause.getGroupingExprs(), aggExprs,
analyzer);
+ createAggInfo(groupingExprs, aggExprs, analyzer);
} else {
createAggInfo(new ArrayList<>(), aggExprs, analyzer);
}
diff --git a/regression-test/data/query/aggregate/aggregate.out
b/regression-test/data/query/aggregate/aggregate.out
index b0358637d9..44bbb9bf0f 100644
--- a/regression-test/data/query/aggregate/aggregate.out
+++ b/regression-test/data/query/aggregate/aggregate.out
@@ -74,3 +74,26 @@ TESTING AGAIN
-- !aggregate --
9223845.04 1607.2585798911111
+-- !aggregate --
+1 2 \\N 98.52
+1 2 12 12.25
+1 2 25 55.52
+1 2 100 134.88420000000002
+1 2 964 0.245
+1 2 5000 67.87
+1 2 5252 12.25
+1 2 5748 271.48
+1 2 6000 \\N
+1 2 8996 98.8777
+
+-- !aggregate --
+\\N
+36
+75
+300
+2892
+15000
+15756
+17244
+18000
+26988
diff --git a/regression-test/suites/query/aggregate/aggregate.groovy
b/regression-test/suites/query/aggregate/aggregate.groovy
index edd7a9b8e1..9296c150a0 100644
--- a/regression-test/suites/query/aggregate/aggregate.groovy
+++ b/regression-test/suites/query/aggregate/aggregate.groovy
@@ -100,4 +100,6 @@ suite("aggregate", "query") {
qt_aggregate """ select variance(c_bigint), variance(c_double) from
${tableName} """
qt_aggregate """ select variance(distinct c_bigint), variance(c_double)
from ${tableName} """
qt_aggregate """ select variance(c_bigint), variance(distinct c_double)
from ${tableName} """
+ qt_aggregate """ select 1 k1, 2 k2, c_bigint k3, sum(c_double) from
${tableName} group by 1, k2, k3 order by k1, k2, k3 """
+ qt_aggregate """ select (k1 + k2) * k3 k4 from (select 1 k1, 2 k2,
c_bigint k3, sum(c_double) from ${tableName} group by 1, k2, k3) t order by k4
"""
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]