Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,23 @@ public void update(AnalysisInfo analyzedJob, TableIf tableIf) {
jobType = analyzedJob.jobType;
if (tableIf != null) {
if (tableIf instanceof OlapTable) {
OlapTable olapTable = (OlapTable) tableIf;
indexesRowCount.putAll(analyzedJob.indexesRowCount);
clearStaleIndexRowCount((OlapTable) tableIf);
clearStaleIndexRowCount(olapTable);
if (analyzedJob.jobColumns.containsAll(
olapTable.getColumnIndexPairs(olapTable.getSchemaAllIndexes(false)
.stream()
.filter(c -> !StatisticsUtil.isUnsupportedType(c.getType()))
.map(Column::getName).collect(Collectors.toSet()))
.stream()
.filter(c -> StatisticsUtil.canCollectColumn(olapTable.getIndexMetaByIndexId(
olapTable.getIndexIdByName(c.first)).getColumnByName(c.second),
olapTable, true, olapTable.getIndexIdByName(c.first)))
.collect(Collectors.toSet()))) {
partitionChanged.set(false);
}
}
rowCount = analyzedJob.rowCount;
if (analyzedJob.jobColumns.containsAll(
tableIf.getColumnIndexPairs(
tableIf.getSchemaAllIndexes(false).stream()
.filter(c -> !StatisticsUtil.isUnsupportedType(c.getType()))
.map(Column::getName).collect(Collectors.toSet())))) {
partitionChanged.set(false);
}
// Set userInject back to false after manual analyze.
if (JobType.MANUAL.equals(jobType) && !analyzedJob.userInject) {
userInjected = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ suite("test_skip_agg_table_value_column") {
createMV("create materialized view mv6 as select key1, sum(value1) from agg group by key1;")
sql """insert into agg values (1, 2, 3, 4, 5), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""

sql """CREATE TABLE agg_partition (
key1 bigint NOT NULL,
key2 bigint NOT NULL,
value1 int SUM NOT NULL,
value2 int MAX NOT NULL,
value3 int MIN NOT NULL
)ENGINE=OLAP
AGGREGATE KEY(`key1`, `key2`)
COMMENT "OLAP"
PARTITION BY RANGE(`key1`)
(PARTITION p1 VALUES [("0"), ("100")),
PARTITION p2 VALUES [("100"), ("10000")))
DISTRIBUTED BY HASH(`key1`) BUCKETS 2
PROPERTIES (
"replication_num" = "1"
);
"""
createMV("create materialized view mv1 as select key2 from agg_partition group by key2;")
createMV("create materialized view mv3 as select key1, key2, sum(value1), max(value2), min(value3) from agg_partition group by key1, key2;")
createMV("create materialized view mv6 as select key1, sum(value1) from agg_partition group by key1;")
sql """analyze table agg_partition(key1) with sync"""
sql """insert into agg_partition values (1, 2, 3, 4, 5), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""

// Test unique table
sql """
CREATE TABLE uni_mor (
Expand All @@ -111,6 +134,34 @@ suite("test_skip_agg_table_value_column") {
"replication_num" = "1"
);
"""
createMV("create materialized view mv1 as select key1, key2 from uni_mor;")
createMV("create materialized view mv6 as select key1, key2, value2, value3 from uni_mor;")
sql """insert into uni_mor values (1, 2, 3, 4, 5), (1, 2, 3, 7, 8), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""

sql """
CREATE TABLE uni_mor_partition (
key1 bigint NOT NULL,
key2 bigint NOT NULL,
value1 int NOT NULL,
value2 int NOT NULL,
value3 int NOT NULL
)ENGINE=OLAP
UNIQUE KEY(`key1`, `key2`)
COMMENT "OLAP"
PARTITION BY RANGE(`key1`)
(PARTITION p1 VALUES [("0"), ("100")),
PARTITION p2 VALUES [("100"), ("10000")))
DISTRIBUTED BY HASH(`key1`) BUCKETS 2
PROPERTIES (
"enable_unique_key_merge_on_write" = false,
"replication_num" = "1"
);
"""
createMV("create materialized view mv1 as select key1, key2 from uni_mor_partition;")
createMV("create materialized view mv6 as select key1, key2, value2, value3 from uni_mor_partition;")
sql """analyze table uni_mor_partition(key1) with sync"""
sql """insert into uni_mor_partition values (1, 2, 3, 4, 5), (1, 2, 3, 7, 8), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""

sql """
CREATE TABLE uni_mow (
key1 bigint NOT NULL,
Expand All @@ -127,9 +178,6 @@ suite("test_skip_agg_table_value_column") {
"replication_num" = "1"
);
"""
createMV("create materialized view mv1 as select key1, key2 from uni_mor;")
createMV("create materialized view mv6 as select key1, key2, value2, value3 from uni_mor;")
sql """insert into uni_mor values (1, 2, 3, 4, 5), (1, 2, 3, 7, 8), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""
createMV("create materialized view mv1 as select key1, key2 from uni_mow;")
createMV("create materialized view mv6 as select key1, key2, value2, value3 from uni_mow;")
sql """insert into uni_mow values (1, 2, 3, 4, 5), (1, 2, 3, 7, 8), (1, 11, 22, 33, 44), (10, 20, 30, 40, 50), (10, 20, 30, 40, 50), (100, 200, 300, 400, 500), (1001, 2001, 3001, 4001, 5001);"""
Expand All @@ -142,9 +190,16 @@ suite("test_skip_agg_table_value_column") {
wait_row_count_reported("test_skip_agg_table_value_column", "agg", 1, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "agg", 2, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "agg", 3, 4, "4")
wait_row_count_reported("test_skip_agg_table_value_column", "agg_partition", 0, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "agg_partition", 1, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "agg_partition", 2, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "agg_partition", 3, 4, "4")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mor", 0, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mor", 1, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mor", 2, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mor_partition", 0, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mor_partition", 1, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mor_partition", 2, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mow", 0, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mow", 1, 4, "5")
wait_row_count_reported("test_skip_agg_table_value_column", "uni_mow", 2, 4, "5")
Expand Down Expand Up @@ -175,6 +230,14 @@ suite("test_skip_agg_table_value_column") {
result = sql """show column stats agg"""
assertEquals(0, result.size())

result = sql """show table stats agg_partition"""
assertEquals("true", result[0][6])
sql """analyze table agg_partition with sync with sample rows 400000"""
result = sql """show column stats agg_partition"""
assertEquals(6, result.size())
result = sql """show table stats agg_partition"""
assertEquals("false", result[0][6])

sql """analyze table uni_mor with sync"""
result = sql """show column stats uni_mor"""
assertEquals(11, result.size())
Expand All @@ -188,6 +251,14 @@ suite("test_skip_agg_table_value_column") {
result = sql """show column stats uni_mor"""
assertEquals(0, result.size())

result = sql """show table stats uni_mor_partition"""
assertEquals("true", result[0][6])
sql """analyze table uni_mor_partition with sync with sample rows 400000"""
result = sql """show column stats uni_mor_partition"""
assertEquals(6, result.size())
result = sql """show table stats uni_mor_partition"""
assertEquals("false", result[0][6])

sql """analyze table uni_mow with sync"""
result = sql """show column stats uni_mow"""
assertEquals(11, result.size())
Expand Down Expand Up @@ -225,4 +296,3 @@ suite("test_skip_agg_table_value_column") {

sql """drop database if exists test_skip_agg_table_value_column"""
}

Loading