This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new b6b765bb0bc branch-4.0: [fix](query cache) fix query cache not hit
when use sort and one phase aggregation #60298 (#60430)
b6b765bb0bc is described below
commit b6b765bb0bcea7022b986ccc0e26340e34d320af
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Feb 3 10:38:17 2026 +0800
branch-4.0: [fix](query cache) fix query cache not hit when use sort and
one phase aggregation #60298 (#60430)
Cherry-picked from #60298
Co-authored-by: 924060929 <[email protected]>
---
.../planner/normalize/QueryCacheNormalizer.java | 5 ++++
.../suites/query_p0/cache/query_cache.groovy | 28 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/normalize/QueryCacheNormalizer.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/normalize/QueryCacheNormalizer.java
index 14fa5746fc5..861e7c5e4cd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/planner/normalize/QueryCacheNormalizer.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/planner/normalize/QueryCacheNormalizer.java
@@ -25,6 +25,7 @@ import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Tablet;
import org.apache.doris.common.Pair;
import org.apache.doris.planner.AggregationNode;
+import org.apache.doris.planner.ExchangeNode;
import org.apache.doris.planner.OlapScanNode;
import org.apache.doris.planner.PlanFragment;
import org.apache.doris.planner.PlanNode;
@@ -128,6 +129,10 @@ public class QueryCacheNormalizer implements Normalizer {
return Optional.of(new CachePoint(planRoot, planRoot));
}
}
+ } else if (planRoot instanceof ExchangeNode) {
+ return Optional.empty();
+ } else if (planRoot.getChildren().size() == 1) {
+ return doComputeCachePoint(planRoot.getChildren().get(0));
}
return Optional.empty();
}
diff --git a/regression-test/suites/query_p0/cache/query_cache.groovy
b/regression-test/suites/query_p0/cache/query_cache.groovy
index 1d699fc8914..981b9f7d340 100644
--- a/regression-test/suites/query_p0/cache/query_cache.groovy
+++ b/regression-test/suites/query_p0/cache/query_cache.groovy
@@ -258,4 +258,32 @@ GROUP BY col_int_undef_signed;
"""
sql "SELECT count(1) FROM query_cache_list_table"
+
+ for (int i = 0; i < 3; ++i) {
+ multi_sql """
+ set enable_query_cache=false;
+ drop table if exists query_cache_schema_change1;
+ create table query_cache_schema_change1(
+ id int,
+ value int
+ )
+ partition by range(id)(
+ partition p1 values[('1'), ('2')),
+ partition p2 values[('2'), ('3')),
+ partition p3 values[('3'), ('4')),
+ partition p4 values[('4'), ('5')),
+ partition p5 values[('5'), ('6'))
+ )distributed by hash(id)
+ properties('replication_num'='1');
+
+ insert into query_cache_schema_change1 values (1, 1), (1, 2),(2,
1), (2, 2), (3, 1), (3, 2),(4, 1), (4, 2),(5, 1), (5, 2);
+
+ set enable_query_cache=true;
+ """
+
+ explain {
+ sql ("select id, count(value) from query_cache_schema_change1
group by id order by id")
+ contains("QUERY_CACHE")
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]