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

eldenmoon 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 0a7bb83fd0d [fix](nereids) fix rule count on index (#53825)
0a7bb83fd0d is described below

commit 0a7bb83fd0da674957ccf8026a47606504e5ecb7
Author: Sun Chenyang <[email protected]>
AuthorDate: Fri Jul 25 10:20:02 2025 +0800

    [fix](nereids) fix rule count on index (#53825)
---
 .../nereids/rules/implementation/AggregateStrategies.java     |  6 +++---
 .../suites/inverted_index_p0/test_count_on_index.groovy       | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

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 acdcf1acfc0..2c65c662356 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
@@ -608,7 +608,7 @@ public class AggregateStrategies implements 
ImplementationRuleFactory {
 
         List<Expression> argumentsOfAggregateFunction = 
normalizeArguments(agg.getAggregateFunctions(), project);
 
-        if (!onlyContainsSlot(argumentsOfAggregateFunction)) {
+        if (!onlyContainsSlotOrLiteral(argumentsOfAggregateFunction)) {
             return agg;
         }
 
@@ -640,9 +640,9 @@ public class AggregateStrategies implements 
ImplementationRuleFactory {
         return arguments;
     }
 
-    private boolean onlyContainsSlot(List<Expression> arguments) {
+    private boolean onlyContainsSlotOrLiteral(List<Expression> arguments) {
         return arguments.stream().allMatch(argument -> {
-            if (argument instanceof SlotReference) {
+            if (argument instanceof SlotReference || argument instanceof 
Literal) {
                 return true;
             }
             return false;
diff --git 
a/regression-test/suites/inverted_index_p0/test_count_on_index.groovy 
b/regression-test/suites/inverted_index_p0/test_count_on_index.groovy
index 6e5a33002f0..9823124df50 100644
--- a/regression-test/suites/inverted_index_p0/test_count_on_index.groovy
+++ b/regression-test/suites/inverted_index_p0/test_count_on_index.groovy
@@ -405,6 +405,17 @@ suite("test_count_on_index_httplogs", "p0") {
             contains "pushAggOp=NONE"
         }
 
+        explain {
+            sql("select COUNT(23) from ${tableName6} where value1 > 20 and 
value2 > 5")
+            contains "pushAggOp=COUNT_ON_INDEX"
+        }
+
+        sql """ set disable_nereids_rules='COUNT_LITERAL_REWRITE'; """
+        explain {
+            sql("select COUNT(23) from ${tableName6} where value1 > 20 and 
value2 > 5")
+            contains "pushAggOp=COUNT_ON_INDEX"
+        }
+
     } finally {
         //try_sql("DROP TABLE IF EXISTS ${testTable}")
     }


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

Reply via email to