Skip to content

Commit

Permalink
[fix](statistics)Skip unknown stats while show cached partition stats. (
Browse files Browse the repository at this point in the history
apache#36243)

Don't show anything if cached partition stats for a column doesn't
exists. Before it will show default value which is misleading.
  • Loading branch information
Jibing-Li authored Jun 13, 2024
1 parent 46a696c commit 72a809b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ public ShowResultSet constructPartitionCachedColumnStats(
for (Map.Entry<PartitionColumnStatisticCacheKey, PartitionColumnStatistic> entry : resultMap.entrySet()) {
PartitionColumnStatisticCacheKey key = entry.getKey();
PartitionColumnStatistic value = entry.getValue();
if (value == null || value.isUnKnown) {
continue;
}
List<String> row = Lists.newArrayList();
row.add(key.colName); // column_name
row.add(key.partId); // partition_name
Expand Down
30 changes: 14 additions & 16 deletions regression-test/suites/statistics/test_partition_stats.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,27 @@ suite("test_partition_stats") {

// Test show cached partition stats.
sql """analyze table part with sync;"""
result = sql """show column cached stats part(id) partition(p1)"""
assertEquals(1, result.size())
Thread.sleep(1000)
for (int i = 0; i < 20; i++) {
result = sql """show column cached stats part(id) partition(p1)"""
if (result[0][3] == "6.0") {
result = sql """show column cached stats part partition(*)"""
if (result.size() == 27) {
logger.info("cache is ready.")
assertEquals("id", result[0][0])
assertEquals("p1", result[0][1])
assertEquals("part", result[0][2])
assertEquals("6.0", result[0][3])
assertEquals("6", result[0][4])
assertEquals("0.0", result[0][5])
assertEquals("1.0", result[0][6])
assertEquals("6.0", result[0][7])
assertEquals("24.0", result[0][8])
assertEquals("N/A", result[0][10])
assertEquals("N/A", result[0][11])
break;
}
logger.info("cache is not ready yet.")
Thread.sleep(1000)
}
result = sql """show column cached stats part(id) partition(p1)"""
assertEquals("id", result[0][0])
assertEquals("p1", result[0][1])
assertEquals("part", result[0][2])
assertEquals("6.0", result[0][3])
assertEquals("6", result[0][4])
assertEquals("0.0", result[0][5])
assertEquals("1.0", result[0][6])
assertEquals("6.0", result[0][7])
assertEquals("24.0", result[0][8])
assertEquals("N/A", result[0][10])
assertEquals("N/A", result[0][11])
result = sql """show column cached stats part partition(p1)"""
assertEquals(9, result.size())
result = sql """show column cached stats part partition(*)"""
Expand Down

0 comments on commit 72a809b

Please sign in to comment.