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

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


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

commit 82a37c1fcbfbf65bfc0a9ac1294e0ff3aff2d676
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jul 25 17:39:38 2025 +0800

    branch-3.1: [fix](nereids) fix rule count on index #53825 (#53879)
    
    Cherry-picked from #53825
    
    Co-authored-by: Sun Chenyang <[email protected]>
---
 .../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 fd73a17c128..977cab0235b 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
@@ -578,7 +578,7 @@ public class AggregateStrategies implements 
ImplementationRuleFactory {
 
         List<Expression> argumentsOfAggregateFunction = 
normalizeArguments(agg.getAggregateFunctions(), project);
 
-        if (!onlyContainsSlot(argumentsOfAggregateFunction)) {
+        if (!onlyContainsSlotOrLiteral(argumentsOfAggregateFunction)) {
             return agg;
         }
 
@@ -610,9 +610,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