This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-4.0-preview in repository https://gitbox.apache.org/repos/asf/doris.git
commit 8f69e8caf0ef7dfd1b6aeab0c23f8ea6ea9c8ebe Author: xy720 <22125576+xy...@users.noreply.github.com> AuthorDate: Thu Apr 11 15:43:48 2024 +0800 [bug](regression) fix regression test test-table-version in cloud_p0 (#33462) Fix regression test test-table-version. introduce by:#32989 --- .../java/org/apache/doris/catalog/OlapTable.java | 3 ++- .../apache/doris/datasource/InternalCatalog.java | 22 ++++++++++++++++------ .../suites/table_p0/test_table_version.groovy | 21 ++++++++++++++++++--- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java index d49de2f6369..786769bd102 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java @@ -2297,12 +2297,13 @@ public class OlapTable extends Table implements MTMVRelatedTableIf { // drop temp partition. if needDropTablet is true, tablets of this temp partition // will be dropped from tablet inverted index. - public void dropTempPartition(String partitionName, boolean needDropTablet) { + public Partition dropTempPartition(String partitionName, boolean needDropTablet) { Partition partition = getPartition(partitionName, true); if (partition != null) { partitionInfo.dropPartition(partition.getId()); tempPartitions.dropPartition(partitionName, needDropTablet); } + return partition; } /* diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index d0e52b9ff05..5c9f3fd4e4e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -1795,10 +1795,11 @@ public class InternalCatalog implements CatalogIf<Database> { // drop long recycleTime = 0; + + Partition partition = null; if (isTempPartition) { - olapTable.dropTempPartition(partitionName, true); + partition = olapTable.dropTempPartition(partitionName, true); } else { - Partition partition = null; if (!clause.isForceDrop()) { partition = olapTable.getPartition(partitionName); if (partition != null) { @@ -1812,14 +1813,23 @@ public class InternalCatalog implements CatalogIf<Database> { } } } - olapTable.dropPartition(db.getId(), partitionName, clause.isForceDrop()); + partition = olapTable.dropPartition(db.getId(), partitionName, clause.isForceDrop()); if (!clause.isForceDrop() && partition != null) { recycleTime = Env.getCurrentRecycleBin().getRecycleTimeById(partition.getId()); } } - long version = olapTable.getNextVersion(); - long versionTime = System.currentTimeMillis(); - olapTable.updateVisibleVersionAndTime(version, versionTime); + + long version = olapTable.getVisibleVersion(); + long versionTime = olapTable.getVisibleVersionTime(); + // Only update table version if drop a non-empty partition + if (partition != null && partition.hasData()) { + versionTime = System.currentTimeMillis(); + if (Config.isNotCloudMode()) { + version = olapTable.getNextVersion(); + olapTable.updateVisibleVersionAndTime(version, versionTime); + } + } + // log DropPartitionInfo info = new DropPartitionInfo(db.getId(), olapTable.getId(), partitionName, isTempPartition, clause.isForceDrop(), recycleTime, version, versionTime); diff --git a/regression-test/suites/table_p0/test_table_version.groovy b/regression-test/suites/table_p0/test_table_version.groovy index 3b60a49b1c4..f8c4c605a52 100644 --- a/regression-test/suites/table_p0/test_table_version.groovy +++ b/regression-test/suites/table_p0/test_table_version.groovy @@ -33,7 +33,8 @@ suite("test_table_version") { PARTITION BY RANGE(`date`) (PARTITION p201701_1000 VALUES [('0000-01-01'), ('2017-02-01')), PARTITION p201702_2000 VALUES [('2017-02-01'), ('2017-03-01')), - PARTITION p201703_all VALUES [('2017-03-01'), ('2017-04-01'))) + PARTITION p201703_3000 VALUES [('2017-03-01'), ('2017-04-01')), + PARTITION p201704_all VALUES [('2017-04-01'), ('2017-05-01'))) DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 PROPERTIES ('replication_num' = '1') ; """ @@ -49,11 +50,25 @@ suite("test_table_version") { assertEquals(2, visibleVersion); sql """ - alter table ${tableNameNum} drop partition p201703_all force; + insert into ${tableNameNum} values(1,"2017-03-15",1); """ visibleVersion = getTableVersion(dbId,tableNameNum); assertEquals(3, visibleVersion); + // drop an empty partition will not add table version + sql """ + alter table ${tableNameNum} drop partition p201704_all force; + """ + visibleVersion = getTableVersion(dbId,tableNameNum); + assertEquals(3, visibleVersion); + + // drop an non-empty partition will add table version + sql """ + alter table ${tableNameNum} drop partition p201703_3000 force; + """ + visibleVersion = getTableVersion(dbId,tableNameNum); + assertEquals(4, visibleVersion); + sql """ ALTER TABLE ${tableNameNum} ADD TEMPORARY PARTITION p201702_2000_1 VALUES [('2017-02-01'), ('2017-03-01')); """ @@ -61,7 +76,7 @@ suite("test_table_version") { ALTER TABLE ${tableNameNum} REPLACE PARTITION (p201702_2000) WITH TEMPORARY PARTITION (p201702_2000_1); """ visibleVersion = getTableVersion(dbId,tableNameNum); - assertEquals(4, visibleVersion); + assertEquals(5, visibleVersion); sql """drop table if exists `${tableNameNum}`""" } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org