[fix](statistics)Fix skip analyze empty table case. (#45441) (#45455)

backport: https://github.com/apache/doris/pull/45441
This commit is contained in:
James
2024-12-16 17:28:05 +08:00
committed by GitHub
parent 17f4c1a17a
commit 7e9f6951c0
3 changed files with 14 additions and 17 deletions

View File

@ -123,15 +123,6 @@ public class StatisticsAutoCollector extends MasterDaemon {
protected void processOneJob(TableIf table, JobPriority priority)
throws DdlException, ExecutionException, InterruptedException {
List<Pair<String, String>> 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<Pair<String, String>> 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<String, String> pair : needRunColumns) {
stringJoiner.add(pair.toString());

View File

@ -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;

View File

@ -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