diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java index 0e32d03039307a..6f50802f395653 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java @@ -136,7 +136,7 @@ public void update(AnalysisInfo analyzedJob, TableIf tableIf) { } jobType = analyzedJob.jobType; if (tableIf != null && analyzedJob.colToPartitions.keySet() - .containsAll(tableIf.getColumns().stream().map(Column::getName).collect( + .containsAll(tableIf.getBaseSchema().stream().map(Column::getName).collect( Collectors.toSet()))) { updatedRows.set(0); } diff --git a/regression-test/suites/statistics/analyze_stats.groovy b/regression-test/suites/statistics/analyze_stats.groovy index 0dfb9d180c5ff1..3f0e5862ba0355 100644 --- a/regression-test/suites/statistics/analyze_stats.groovy +++ b/regression-test/suites/statistics/analyze_stats.groovy @@ -1249,4 +1249,30 @@ PARTITION `p599` VALUES IN (599) assert all_finished(show_result) + // unique table update rows + sql """ + CREATE TABLE unique_tbl_update_rows_test (col1 varchar(11451) not null, + col2 int not null, col3 int not null, col4 int not null) + DUPLICATE KEY(`col1`) + DISTRIBUTED BY HASH(col1) + BUCKETS 3 + PROPERTIES( + "replication_num"="1" + ); + """ + + sql """insert into unique_tbl_update_rows_test values('21',5,1,7); """ + sql """ANALYZE TABLE unique_tbl_update_rows_test WITH SYNC""" + sql """insert into unique_tbl_update_rows_test values('21',5,1,7); """ + sql """ANALYZE TABLE unique_tbl_update_rows_test WITH SYNC""" + def unique_table_update_rows_result = sql """SHOW TABLE STATS unique_tbl_update_rows_test""" + def check_update_rows = { r -> + for (int i = 0; i < r.size; i++) { + if (r[i][0] == "0") { + return true + } + } + return false + } + check_update_rows(unique_table_update_rows_result) }