This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new cd29e7901ec [improve](nereids) support agg function of count(const
value) pushdown #26677 (#27499)
cd29e7901ec is described below
commit cd29e7901ec6a11d01ac25deaf6cb142e98bc750
Author: zhangstar333 <[email protected]>
AuthorDate: Thu Nov 23 22:31:08 2023 +0800
[improve](nereids) support agg function of count(const value) pushdown
#26677 (#27499)
support sql: select count(1)-count(not null) from table, the agg of count
could push down.
---
.../rules/rewrite/CountLiteralToCountStar.java | 2 +-
.../explain/test_pushdown_explain.groovy | 33 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CountLiteralToCountStar.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CountLiteralToCountStar.java
index d50d8b5a8e4..fc08273b84f 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CountLiteralToCountStar.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CountLiteralToCountStar.java
@@ -57,7 +57,7 @@ public class CountLiteralToCountStar extends
OneRewriteRuleFactory {
.filter(this::isCountLiteral)
.forEach(c -> replaced.put(c, new Count()));
expr = expr.rewriteUp(s -> replaced.getOrDefault(s, s));
- changed = !replaced.isEmpty();
+ changed |= !replaced.isEmpty();
newExprs.add((NamedExpression) expr);
}
return changed;
diff --git
a/regression-test/suites/nereids_p0/explain/test_pushdown_explain.groovy
b/regression-test/suites/nereids_p0/explain/test_pushdown_explain.groovy
index c7fe7d7b93e..091ae98bbb3 100644
--- a/regression-test/suites/nereids_p0/explain/test_pushdown_explain.groovy
+++ b/regression-test/suites/nereids_p0/explain/test_pushdown_explain.groovy
@@ -25,4 +25,37 @@ suite("test_pushdown_explain") {
contains "PREDICATES:"
}
qt_select "select k1 from baseall where k1 = 1"
+
+ sql "DROP TABLE IF EXISTS test_lineorder"
+ sql """ CREATE TABLE `test_lineorder` (
+ `lo_orderkey` INT NOT NULL COMMENT '\"\"',
+ `lo_linenumber` INT NOT NULL COMMENT '\"\"',
+ `lo_shipmode` VARCHAR(11) NOT NULL COMMENT '\"\"'
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`lo_orderkey`)
+ DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 48
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ ); """
+ sql """ insert into test_lineorder values(1,2,"asd"); """
+ explain {
+ sql("select count(1) from test_lineorder;")
+ contains "pushAggOp=COUNT"
+ }
+ explain {
+ sql("select count(*) from test_lineorder;")
+ contains "pushAggOp=COUNT"
+ }
+ explain {
+ sql("select count(1) - count(lo_shipmode) from test_lineorder;")
+ contains "pushAggOp=COUNT"
+ }
+ explain {
+ sql("select count(lo_orderkey) from test_lineorder;")
+ contains "pushAggOp=COUNT"
+ }
+ explain {
+ sql("select count(cast(lo_orderkey as bigint)) from test_lineorder;")
+ contains "pushAggOp=COUNT"
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]