From 8ae0ac3fdb8a1bc5817a794b9ffb6e4ceac55c02 Mon Sep 17 00:00:00 2001 From: englefly Date: Wed, 18 Oct 2023 08:34:21 +0800 Subject: [PATCH] ut --- .../apache/doris/nereids/stats/StatsCalculator.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java index a219cdb1c6bdf9..6ee5c642b90e50 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java @@ -631,10 +631,14 @@ private Statistics computeCatalogRelation(CatalogRelation catalogRelation) { if (colName == null) { throw new RuntimeException(String.format("Invalid slot: %s", slotReference.getExprId())); } - ColumnStatistic cache = ConnectContext.get().getSessionVariable().enableStats - && FeConstants.enableInternalSchemaDb - ? shouldIgnoreThisCol - ? ColumnStatistic.UNKNOWN : getColumnStatistic(table, colName) : ColumnStatistic.UNKNOWN; + ColumnStatistic cache; + if (ConnectContext.get() == null || !ConnectContext.get().getSessionVariable().enableStats + || !FeConstants.enableInternalSchemaDb + || shouldIgnoreThisCol) { + cache = ColumnStatistic.UNKNOWN; + } else { + cache = getColumnStatistic(table, colName); + } if (cache.avgSizeByte <= 0) { cache = new ColumnStatisticBuilder(cache) .setAvgSizeByte(slotReference.getColumn().get().getType().getSlotSize())