This is an automated email from the ASF dual-hosted git repository.
morningman 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 9a4baf7ccf0 [fix](Nereids)Fix the bug that count(*) does not push down
for tables with only one column. (#25222)
9a4baf7ccf0 is described below
commit 9a4baf7ccf0cacdd5dc78dcc4c63b10e2c6dffe3
Author: daidai <[email protected]>
AuthorDate: Wed Oct 11 10:17:30 2023 -0500
[fix](Nereids)Fix the bug that count(*) does not push down for tables with
only one column. (#25222)
after pr #22115 .
Fixed the bug that when selecting count(*) from table, if the table has
only one column, the aggregate count is not pushed down.
---
.../org/apache/doris/nereids/rules/RuleType.java | 1 +
.../rules/implementation/AggregateStrategies.java | 7 ++
.../hive/test_select_count_optimize.groovy | 102 +++++++++++++++++++++
3 files changed, 110 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
index 51a20847ce5..83196453190 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
@@ -342,6 +342,7 @@ public enum RuleType {
LOGICAL_ASSERT_NUM_ROWS_TO_PHYSICAL_ASSERT_NUM_ROWS(RuleTypeClass.IMPLEMENTATION),
STORAGE_LAYER_AGGREGATE_WITHOUT_PROJECT(RuleTypeClass.IMPLEMENTATION),
STORAGE_LAYER_AGGREGATE_WITH_PROJECT(RuleTypeClass.IMPLEMENTATION),
+
STORAGE_LAYER_AGGREGATE_WITHOUT_PROJECT_FOR_FILE_SCAN(RuleTypeClass.IMPLEMENTATION),
STORAGE_LAYER_AGGREGATE_WITH_PROJECT_FOR_FILE_SCAN(RuleTypeClass.IMPLEMENTATION),
COUNT_ON_INDEX(RuleTypeClass.IMPLEMENTATION),
COUNT_ON_INDEX_WITHOUT_PROJECT(RuleTypeClass.IMPLEMENTATION),
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
index 166ddd3bd9a..511312ddd82 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
@@ -161,6 +161,13 @@ public class AggregateStrategies implements
ImplementationRuleFactory {
return storageLayerAggregate(agg, project, olapScan,
ctx.cascadesContext);
})
),
+
RuleType.STORAGE_LAYER_AGGREGATE_WITHOUT_PROJECT_FOR_FILE_SCAN.build(
+ logicalAggregate(
+ logicalFileScan()
+ )
+ .when(agg -> agg.isNormalized() &&
enablePushDownNoGroupAgg())
+ .thenApply(ctx -> storageLayerAggregate(ctx.root, null,
ctx.root.child(), ctx.cascadesContext))
+ ),
RuleType.STORAGE_LAYER_AGGREGATE_WITH_PROJECT_FOR_FILE_SCAN.build(
logicalAggregate(
logicalProject(
diff --git
a/regression-test/suites/external_table_p2/hive/test_select_count_optimize.groovy
b/regression-test/suites/external_table_p2/hive/test_select_count_optimize.groovy
index fadf452bdb5..840ab77da2c 100644
---
a/regression-test/suites/external_table_p2/hive/test_select_count_optimize.groovy
+++
b/regression-test/suites/external_table_p2/hive/test_select_count_optimize.groovy
@@ -88,6 +88,108 @@ suite("test_select_count_optimize",
"p2,external,hive,external_remote,external_r
qt_sql """ select count(*) as a from tpch_1000.nation group by
n_regionkey order by a;"""
+ explain {
+
+ sql "select count(*) from tpch_1000_parquet.nation;"
+
+ contains "pushdown agg=COUNT"
+ }
+
+ explain {
+
+ sql "select count(1) from tpch_1000_parquet.nation;"
+
+ contains "pushdown agg=COUNT"
+ }
+
+
+ explain {
+
+ sql "select count(2) from tpch_1000_parquet.nation;"
+
+ contains "pushdown agg=COUNT"
+ }
+
+
+ explain {
+
+ sql "select count(n_name) from tpch_1000_parquet.nation;"
+
+ notContains "pushdown agg=COUNT"
+ }
+
+ explain {
+
+ sql "select count(n_name) from tpch_1000_parquet.nation where
n_nationkey = 1;"
+
+ notContains "pushdown agg=COUNT"
+ }
+
+ explain {
+
+ sql "select count(*) from tpch_1000_parquet.nation group by
n_regionkey ;"
+
+ notContains "pushdown agg=COUNT"
+ }
+
+
+ explain {
+
+ sql " select count(*) from multi_catalog.test_csv_format_error; "
+
+ contains "pushdown agg=COUNT"
+ }
+
+ explain {
+ sql "select count(*) from multi_catalog.hits_orc ; "
+
+ contains "pushdown agg=COUNT"
+
+ }
+
+
+ explain {
+ sql "select count(*) from multi_catalog.hits_orc ; "
+
+ contains "pushdown agg=COUNT"
+
+ }
+
+
+ explain {
+
+ sql "select count(*) from multi_catalog.parquet_one_column;"
+
+ contains "pushdown agg=COUNT"
+ }
+
+ explain {
+
+ sql "select count(col1) from multi_catalog.parquet_one_column;"
+
+ notContains "pushdown agg=COUNT"
+ }
+
+ explain {
+
+ sql "select count(*) from multi_catalog.parquet_two_column;"
+
+ contains "pushdown agg=COUNT"
+ }
+ explain {
+
+ sql "select count(*) from multi_catalog.parquet_two_column where
col1 = 1;"
+
+ notContains "pushdown agg=COUNT"
+ }
+
+
+ explain {
+
+ sql "select count(*) from multi_catalog.logs2_orc;"
+
+ contains "pushdown agg=COUNT"
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]