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/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new fd6fb90 [Bug] Hit none partition cache, but hit range is still right (#5065) fd6fb90 is described below commit fd6fb90a5a83150c2fb3821f1942ce1d027b8824 Author: xinghuayu007 <1450306...@qq.com> AuthorDate: Thu Dec 31 09:40:31 2020 +0800 [Bug] Hit none partition cache, but hit range is still right (#5065) Doris supports two kinds of cache mode: sql_cache and partition_cache. sql_cache takes sql string as key and cache the whole data. partition_cache splits the data into many partition data and caches them differently. Therefore a query may hit part of the partition_cache data. If a query hits the left part of the data, we call the hit range is left. If a query hits the right part of the data, we call the hit range is right. And if a query hits the whole part of the data, we call the hit range is full. A query does not hit any partition cache, but the algorithm still returns hit range right. It should return hit range none. Related issue: #5136 --- .../org/apache/doris/qe/cache/PartitionRange.java | 12 +++++------ .../org/apache/doris/qe/PartitionCacheTest.java | 25 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java index 7e3785a..aa09ad8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java @@ -371,15 +371,15 @@ public class PartitionRange { if (end < begin) { hitRange = Cache.HitRange.Full; return hitRange; - } - - if (end == partitionSingleList.size() - 1) { + } else if (begin > 0 && end == partitionSingleList.size() - 1) { hitRange = Cache.HitRange.Left; - } - if (begin == 0) { + } else if (begin == 0 && end < partitionSingleList.size() - 1) { hitRange = Cache.HitRange.Right; + } else if (begin > 0 && end < partitionSingleList.size() - 1) { + hitRange = Cache.HitRange.Middle; + } else { + hitRange = Cache.HitRange.None; } - rangeList.add(partitionSingleList.get(begin)); rangeList.add(partitionSingleList.get(end)); LOG.info("the new range for scan be is [{},{}], hit range", rangeList.get(0).getCacheKey().realValue(), diff --git a/fe/fe-core/src/test/java/org/apache/doris/qe/PartitionCacheTest.java b/fe/fe-core/src/test/java/org/apache/doris/qe/PartitionCacheTest.java index d0ba4cc..4f1525f 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/qe/PartitionCacheTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/qe/PartitionCacheTest.java @@ -846,5 +846,30 @@ public class PartitionCacheTest { Assert.fail(e.getMessage()); } } + + @Test + public void testNotHitPartition() throws Exception { + Catalog.getCurrentSystemInfo(); + StatementBase parseStmt = parseSql( + "SELECT eventdate, COUNT(userid) FROM appevent WHERE eventdate>=\"2020-01-12\" and eventdate<=\"2020-01-14\" GROUP BY eventdate" + ); + List<ScanNode> scanNodes = Lists.newArrayList(createEventScanNode()); + CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes); + ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01 + try { + PartitionCache cache = (PartitionCache) ca.getCache(); + cache.rewriteSelectStmt(null); + PartitionRange range = cache.getPartitionRange(); + range.analytics(); + hitRange = range.buildDiskPartitionRange(newRangeList); + Assert.assertEquals(hitRange,Cache.HitRange.None); + Assert.assertEquals(newRangeList.size(), 2); + Assert.assertEquals(newRangeList.get(0).getCacheKey().realValue(), 20200112); + Assert.assertEquals(newRangeList.get(1).getCacheKey().realValue(), 20200114); + } catch (Exception e) { + LOG.warn("ex={}", e); + Assert.fail(e.getMessage()); + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org