This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5d9c555dcf7 [minor](stats) Fix potential npe when loading stats
(#27200)
5d9c555dcf7 is described below
commit 5d9c555dcf7835eee733a75dc2682a85696c2cf6
Author: AKIRA <[email protected]>
AuthorDate: Thu Nov 23 16:37:58 2023 +0900
[minor](stats) Fix potential npe when loading stats (#27200)
Besides, lower down the log level of loading stats from warning to debug,
since it doesn't such matter for workflow.
---
.../statistics/ColumnStatisticsCacheLoader.java | 5 ++--
.../org/apache/doris/statistics/CacheTest.java | 31 ++++++++++------------
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java
index 281a0e82502..22f0cad9d00 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java
@@ -50,11 +50,10 @@ public class ColumnStatisticsCacheLoader extends
StatisticsCacheLoader<Optional<
}
// Load from data source metadata
try {
- TableIf table =
Env.getCurrentEnv().getCatalogMgr().getCatalog(key.catalogId)
-
.getDbOrMetaException(key.dbId).getTableOrMetaException(key.tableId);
+ TableIf table = StatisticsUtil.findTable(key.catalogId, key.dbId,
key.tableId);
columnStatistic = table.getColumnStatistic(key.colName);
} catch (Exception e) {
- LOG.warn(String.format("Exception to get column statistics by
metadata. [Catalog:%d, DB:%d, Table:%d]",
+ LOG.debug(String.format("Exception to get column statistics by
metadata. [Catalog:%d, DB:%d, Table:%d]",
key.catalogId, key.dbId, key.tableId), e);
}
return columnStatistic;
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/statistics/CacheTest.java
b/fe/fe-core/src/test/java/org/apache/doris/statistics/CacheTest.java
index 95ed5023e36..cc1fa8353b1 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/statistics/CacheTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/statistics/CacheTest.java
@@ -20,6 +20,7 @@ package org.apache.doris.statistics;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.PrimitiveType;
+import org.apache.doris.catalog.TableIf;
import org.apache.doris.catalog.Type;
import org.apache.doris.catalog.external.HMSExternalDatabase;
import org.apache.doris.catalog.external.HMSExternalTable;
@@ -54,6 +55,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@@ -221,6 +223,11 @@ public class CacheTest extends TestWithFeService {
public List<ResultRow> execStatisticQuery(String sql) {
return null;
}
+
+ @Mock
+ public TableIf findTable(long catalogId, long dbId, long tblId) {
+ return table;
+ }
};
new MockUp<Env>() {
@Mock
@@ -229,26 +236,16 @@ public class CacheTest extends TestWithFeService {
}
};
- new Expectations() {
- {
- env.getCatalogMgr();
- result = mgr;
-
- mgr.getCatalog(1);
- result = catalog;
-
- catalog.getDbOrMetaException(1);
- result = db;
-
- db.getTableOrMetaException(1);
- result = table;
-
- table.getColumnStatistic("col");
- result = new ColumnStatistic(1, 2,
+ new MockUp<HMSExternalTable>() {
+ @Mock
+ public Optional<ColumnStatistic> getColumnStatistic(String
colName) {
+ return Optional.of(new ColumnStatistic(1, 2,
null, 3, 4, 5, 6, 7,
- null, null, false, null, new Date().toString(), null);
+ null, null, false, null,
+ new Date().toString(), null));
}
};
+
try {
StatisticsCache statisticsCache = new StatisticsCache();
ColumnStatistic columnStatistic =
statisticsCache.getColumnStatistics(1, 1, 1, "col");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]