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 2023/06/25 11:14:27 UTC
[doris] branch master updated: [fix](planner) fix push filter through agg #21080
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 638aa41988 [fix](planner) fix push filter through agg #21080
638aa41988 is described below
commit 638aa41988040a522e0b9022ef42632983d62da5
Author: AKIRA <33...@users.noreply.github.com>
AuthorDate: Sun Jun 25 20:14:20 2023 +0900
[fix](planner) fix push filter through agg #21080
In the previous implementation, the check for groupby exprs was ignored. Add this necessary check to make sure it would work
You could reproduce it by runnning belowing sql:
CREATE TABLE t_push_filter_through_agg (col1 varchar(11451) not null, col2 int not null, col3 int not null)
UNIQUE KEY(col1)
DISTRIBUTED BY HASH(col1)
BUCKETS 3
PROPERTIES(
"replication_num"="1"
);
CREATE VIEW `view_i` AS
SELECT
`b`.`col1` AS `col1`,
`b`.`col2` AS `col2`
FROM
(
SELECT
`col1` AS `col1`,
sum(`cost`) AS `col2`
FROM
(
SELECT
`col1` AS `col1`,
sum(CAST(`col3` AS INT)) AS `cost`
FROM
`t_push_filter_through_agg`
GROUP BY
`col1`
) a
GROUP BY
`col1`
) b;
SELECT SUM(`total_cost`) FROM view_a WHERE `dt` BETWEEN '2023-06-12' AND '2023-06-18' LIMIT 1;
---
.../apache/doris/planner/SingleNodePlanner.java | 6 +++
.../query_p0/aggregate/push_filter_through_agg.out | 4 ++
.../aggregate/push_filter_through_agg.groovy | 59 ++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index 01de183592..c809ac177e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -2768,6 +2768,12 @@ public class SingleNodePlanner {
}
}
}
+ GroupByClause groupByClause = stmt.getGroupByClause();
+ List<Expr> exprs = groupByClause.getGroupingExprs();
+ if (!exprs.contains(sourceExpr)) {
+ isAllSlotReferToGroupBys = false;
+ break;
+ }
}
if (isAllSlotReferToGroupBys) {
diff --git a/regression-test/data/query_p0/aggregate/push_filter_through_agg.out b/regression-test/data/query_p0/aggregate/push_filter_through_agg.out
new file mode 100644
index 0000000000..e011475a94
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/push_filter_through_agg.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+\N
+
diff --git a/regression-test/suites/query_p0/aggregate/push_filter_through_agg.groovy b/regression-test/suites/query_p0/aggregate/push_filter_through_agg.groovy
new file mode 100644
index 0000000000..82ee73c4f2
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/push_filter_through_agg.groovy
@@ -0,0 +1,59 @@
+// 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("push_filter_through_agg") {
+ sql """
+ CREATE TABLE t_push_filter_through_agg (col1 varchar(11451) not null, col2 int not null, col3 int not null)
+ UNIQUE KEY(col1)
+ DISTRIBUTED BY HASH(col1)
+ BUCKETS 3
+ PROPERTIES(
+ "replication_num"="1"
+ );
+ """
+
+ sql """
+ CREATE VIEW `view_i` AS
+ SELECT
+ `b`.`col1` AS `col1`,
+ `b`.`col2` AS `col2`
+ FROM
+ (
+ SELECT
+ `col1` AS `col1`,
+ sum(`cost`) AS `col2`
+ FROM
+ (
+ SELECT
+ `col1` AS `col1`,
+ sum(
+ CAST(`col3` AS INT)
+ ) AS `cost`
+ FROM
+ `t_push_filter_through_agg`
+ GROUP BY
+ `col1`
+ ) a
+ GROUP BY
+ `col1`
+ ) b;
+ """
+
+ qt_sql """
+ SELECT SUM(`col2`) FROM view_i WHERE `col1` BETWEEN 10 AND 20 LIMIT 1;
+ """
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org