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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new a936c5132d9 branch-2.1: [fix](nereids) fix rule count on index #53825 
(#53878)
a936c5132d9 is described below

commit a936c5132d984eb531f3c5ca9c2f2d808e27ad6d
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Jul 26 23:24:27 2025 +0800

    branch-2.1: [fix](nereids) fix rule count on index #53825 (#53878)
    
    Cherry-picked from #53825
    
    Co-authored-by: Sun Chenyang <suncheny...@selectdb.com>
---
 .../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 8660034a2b5..10efb483951 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
@@ -542,7 +542,7 @@ public class AggregateStrategies implements 
ImplementationRuleFactory {
 
         List<Expression> argumentsOfAggregateFunction = 
normalizeArguments(agg.getAggregateFunctions(), project);
 
-        if (!onlyContainsSlot(argumentsOfAggregateFunction)) {
+        if (!onlyContainsSlotOrLiteral(argumentsOfAggregateFunction)) {
             return agg;
         }
 
@@ -574,9 +574,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 9e0f4f7da2a..0264d082d4b 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
@@ -370,6 +370,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: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to