This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new d0888cbd045 branch-4.1: [fix](fe) Return unknown stats for system
tables #62913 (#63010)
d0888cbd045 is described below
commit d0888cbd04574c131fc6117dca28da12a563c535
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue May 12 19:22:18 2026 +0800
branch-4.1: [fix](fe) Return unknown stats for system tables #62913 (#63010)
Cherry-picked from #62913
Co-authored-by: yujun <[email protected]>
---
.../apache/doris/statistics/StatisticsCache.java | 6 +++
.../doris/statistics/StatisticsCacheTest.java | 46 ++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java
index e8a5c519660..6ba538b81a3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsCache.java
@@ -401,6 +401,9 @@ public class StatisticsCache {
if (ctx != null && ctx.getState().isPlanWithUnKnownColumnStats()) {
return ColumnStatistic.UNKNOWN;
}
+ if (StatisticConstants.isSystemTable(olapTable)) {
+ return ColumnStatistic.UNKNOWN;
+ }
return doGetColumnStatistics(
catalogId, schemaId, tableId, selectIndexId, colName, ctx
);
@@ -411,6 +414,9 @@ public class StatisticsCache {
if (ctx != null && ctx.getState().isPlanWithUnKnownColumnStats()) {
return PartitionColumnStatistic.UNKNOWN;
}
+ if (StatisticConstants.isSystemTable(olapTable)) {
+ return PartitionColumnStatistic.UNKNOWN;
+ }
return doGetPartitionColumnStatistics(
catalogId, schemaId, tableId, selectIndexId, partName,
colName
);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsCacheTest.java
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsCacheTest.java
index cb1dffbe106..712be0ef0b6 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsCacheTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsCacheTest.java
@@ -17,6 +17,11 @@
package org.apache.doris.statistics;
+import org.apache.doris.catalog.DatabaseIf;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.common.FeConstants;
+import org.apache.doris.datasource.CatalogIf;
+import org.apache.doris.nereids.trees.plans.algebra.OlapScan;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.utframe.UtFrameUtils;
@@ -24,6 +29,8 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
+import org.mockito.Mockito;
public class StatisticsCacheTest {
@@ -87,4 +94,43 @@ public class StatisticsCacheTest {
ConnectContext.get().getState().setPlanWithUnKnownColumnStats(prevFlag);
}
}
+
+ @Test
+ public void testOlapTableStatisticsSkipSystemTable() {
+ try (MockedConstruction<ColumnStatisticsCacheLoader> columnLoader =
Mockito.mockConstruction(
+ ColumnStatisticsCacheLoader.class);
+ MockedConstruction<PartitionColumnStatisticCacheLoader>
partitionLoader = Mockito.mockConstruction(
+ PartitionColumnStatisticCacheLoader.class)) {
+ StatisticsCache cache = new StatisticsCache();
+ StatisticsCache.OlapTableStatistics olapTableStats =
+
cache.getOlapTableStats(mockSystemOlapScan(FeConstants.INTERNAL_DB_NAME));
+
+ Assertions.assertEquals(ColumnStatistic.UNKNOWN,
+ olapTableStats.getColumnStatistics("col",
ConnectContext.get()));
+ Assertions.assertEquals(PartitionColumnStatistic.UNKNOWN,
+ olapTableStats.getPartitionColumnStatistics("p1", "col",
ConnectContext.get()));
+
+ Mockito.verifyNoInteractions(columnLoader.constructed().get(0));
+ Mockito.verifyNoInteractions(partitionLoader.constructed().get(0));
+ }
+ }
+
+ private OlapScan mockSystemOlapScan(String dbName) {
+ CatalogIf catalog = Mockito.mock(CatalogIf.class);
+ Mockito.when(catalog.getId()).thenReturn(1L);
+ DatabaseIf database = Mockito.mock(DatabaseIf.class);
+ Mockito.when(database.getId()).thenReturn(2L);
+ Mockito.when(database.getCatalog()).thenReturn(catalog);
+
+ OlapTable table = Mockito.mock(OlapTable.class);
+ Mockito.when(table.getQualifiedDbName()).thenReturn(dbName);
+ Mockito.when(table.getDatabase()).thenReturn(database);
+ Mockito.when(table.getId()).thenReturn(3L);
+ Mockito.when(table.getBaseIndexId()).thenReturn(4L);
+
+ OlapScan scan = Mockito.mock(OlapScan.class);
+ Mockito.when(scan.getTable()).thenReturn(table);
+ Mockito.when(scan.getSelectedIndexId()).thenReturn(4L);
+ return scan;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]