Skip to content

Commit

Permalink
[improvement](statistics)Support cloud version set row count to -1 wh…
Browse files Browse the repository at this point in the history
…en not reported. (#41015)

Follow up #40457. Support cloud
version.
  • Loading branch information
Jibing-Li authored Sep 24, 2024
1 parent cf2e8f8 commit 0b92e5a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ public void afterCommitTxnResp(CommitTxnResponse commitTxnResponse) {
if (partition == null) {
continue;
}
if (version == 2) {
partition.getMaterializedIndices(MaterializedIndex.IndexExtState.ALL)
.stream().forEach(i -> i.setRowCountReported(false));
}
partition.setCachedVisibleVersion(version, commitTxnResponse.getVersionUpdateTimeMs());
LOG.info("Update Partition. transactionId:{}, table_id:{}, partition_id:{}, version:{}, update time:{}",
txnId, tableId, partition.getId(), version, commitTxnResponse.getVersionUpdateTimeMs());
Expand Down
122 changes: 58 additions & 64 deletions regression-test/suites/statistics/test_analyze_mv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,13 @@ suite("test_analyze_mv") {
)
"""
def result_row
if (!isCloudMode()) {
// Test row count report and report for nereids
result_row = sql """show index stats mvTestDup mvTestDup"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mvTestDup", result_row[0][1])
assertEquals("0", result_row[0][3])
assertEquals("-1", result_row[0][4])
}
// Test row count report and report for nereids
result_row = sql """show index stats mvTestDup mvTestDup"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mvTestDup", result_row[0][1])
assertEquals("0", result_row[0][3])
assertEquals("-1", result_row[0][4])

createMV("create materialized view mv1 as select key1 from mvTestDup;")
createMV("create materialized view mv2 as select key2 from mvTestDup;")
Expand Down Expand Up @@ -476,33 +474,31 @@ suite("test_analyze_mv") {
return;
}

if (!isCloudMode()) {
// Test row count report and report for nereids
result_row = sql """show index stats mvTestDup mvTestDup"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mvTestDup", result_row[0][1])
assertEquals("6", result_row[0][3])
assertEquals("6", result_row[0][4])
result_row = sql """show index stats mvTestDup mv1"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv1", result_row[0][1])
assertEquals("6", result_row[0][3])
assertEquals("6", result_row[0][4])
result_row = sql """show index stats mvTestDup mv2"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv2", result_row[0][1])
assertEquals("6", result_row[0][3])
assertEquals("6", result_row[0][4])
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("4", result_row[0][3])
assertEquals("4", result_row[0][4])
}
// Test row count report and report for nereids
result_row = sql """show index stats mvTestDup mvTestDup"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mvTestDup", result_row[0][1])
assertEquals("6", result_row[0][3])
assertEquals("6", result_row[0][4])
result_row = sql """show index stats mvTestDup mv1"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv1", result_row[0][1])
assertEquals("6", result_row[0][3])
assertEquals("6", result_row[0][4])
result_row = sql """show index stats mvTestDup mv2"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv2", result_row[0][1])
assertEquals("6", result_row[0][3])
assertEquals("6", result_row[0][4])
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("4", result_row[0][3])
assertEquals("4", result_row[0][4])

sql """analyze table mvTestDup with sample rows 4000000"""
wait_analyze_finish("mvTestDup")
Expand Down Expand Up @@ -651,37 +647,35 @@ suite("test_analyze_mv") {
verifyTaskStatus(result_sample, "mva_MIN__`value3`", "mv3")
verifyTaskStatus(result_sample, "mva_SUM__CAST(`value1` AS bigint)", "mv3")

if (!isCloudMode()) {
// Test row count report and report for nereids
sql """truncate table mvTestDup"""
// Test row count report and report for nereids
sql """truncate table mvTestDup"""
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("0", result_row[0][3])
assertEquals("-1", result_row[0][4])

for (int i = 0; i < 120; i++) {
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("0", result_row[0][3])
assertEquals("-1", result_row[0][4])

for (int i = 0; i < 120; i++) {
result_row = sql """show index stats mvTestDup mv3"""
logger.info("mv3 stats: " + result_row)
if (result_row[0][4] == "0") {
break;
}
Thread.sleep(5000)
logger.info("mv3 stats: " + result_row)
if (result_row[0][4] == "0") {
break;
}
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("0", result_row[0][3])
assertEquals("0", result_row[0][4])
sql """insert into mvTestDup values (1, 2, 3, 4, 5), (1, 2, 3, 4, 5), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("-1", result_row[0][4])
Thread.sleep(5000)
}
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("0", result_row[0][3])
assertEquals("0", result_row[0][4])
sql """insert into mvTestDup values (1, 2, 3, 4, 5), (1, 2, 3, 4, 5), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""
result_row = sql """show index stats mvTestDup mv3"""
assertEquals(1, result_row.size())
assertEquals("mvTestDup", result_row[0][0])
assertEquals("mv3", result_row[0][1])
assertEquals("-1", result_row[0][4])

// Test alter column stats
sql """drop stats mvTestDup"""
Expand Down

0 comments on commit 0b92e5a

Please sign in to comment.