From 7e9f6951c040666757bcbaef2004fb4c5c0f749c Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Dec 2024 17:28:05 +0800 Subject: [PATCH] [fix](statistics)Fix skip analyze empty table case. (#45441) (#45455) backport: https://github.com/apache/doris/pull/45441 --- .../statistics/StatisticsAutoCollector.java | 18 +++++++++--------- .../StatisticsAutoCollectorTest.java | 5 +++++ .../suites/statistics/test_analyze_mv.groovy | 8 -------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java index 1d7818a8e8..574b25da42 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java @@ -123,15 +123,6 @@ public class StatisticsAutoCollector extends MasterDaemon { protected void processOneJob(TableIf table, JobPriority priority) throws DdlException, ExecutionException, InterruptedException { - List> needRunColumns = table.getColumnIndexPairs( - table.getSchemaAllIndexes(false) - .stream() - .filter(c -> !StatisticsUtil.isUnsupportedType(c.getType())) - .map(Column::getName) - .collect(Collectors.toSet())); - if (needRunColumns == null || needRunColumns.isEmpty()) { - return; - } AnalysisMethod analysisMethod = table.getDataSize(true) >= StatisticsUtil.getHugeTableLowerBoundSizeInBytes() ? AnalysisMethod.SAMPLE : AnalysisMethod.FULL; @@ -151,6 +142,15 @@ public class StatisticsAutoCollector extends MasterDaemon { } return; } + List> needRunColumns = table.getColumnIndexPairs( + table.getSchemaAllIndexes(false) + .stream() + .filter(c -> !StatisticsUtil.isUnsupportedType(c.getType())) + .map(Column::getName) + .collect(Collectors.toSet())); + if (needRunColumns == null || needRunColumns.isEmpty()) { + return; + } StringJoiner stringJoiner = new StringJoiner(",", "[", "]"); for (Pair pair : needRunColumns) { stringJoiner.add(pair.toString()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java index d687d111d2..6c13bbc0f7 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java @@ -67,6 +67,11 @@ public class StatisticsAutoCollectorTest { count[0]++; return Pair.of(null, JobPriority.LOW); } + + @Mock + protected void processOneJob(TableIf table, JobPriority priority) { + return; + } }; count[0] = 0; count[1] = 0; diff --git a/regression-test/suites/statistics/test_analyze_mv.groovy b/regression-test/suites/statistics/test_analyze_mv.groovy index a4263975c2..f52295469d 100644 --- a/regression-test/suites/statistics/test_analyze_mv.groovy +++ b/regression-test/suites/statistics/test_analyze_mv.groovy @@ -717,14 +717,6 @@ suite("test_analyze_mv") { empty_test = sql """show auto analyze mvTestDup""" assertEquals(0, empty_test.size()) empty_test = sql """show column stats mvTestDup""" - for (int i = 0; i < 100; i++) { - empty_test = sql """show column stats mvTestDup""" - if (empty_test.size() != 0) { - logger.info("async delete is not finished yet.") - Thread.sleep(1000) - } - break - } assertEquals(0, empty_test.size()) // ** End of embedded test