This is an automated email from the ASF dual-hosted git repository. pengxiangyu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 69d95c857a [feature](remote)Add alter storage policy (#15381) 69d95c857a is described below commit 69d95c857a55e0f58e603226b8071c9644e1ce3f Author: pengxiangyu <diablo...@163.com> AuthorDate: Wed Dec 28 16:09:06 2022 +0800 [feature](remote)Add alter storage policy (#15381) * add alter storage policy * add alter storage policy * add alter storage policy --- .../src/main/java/org/apache/doris/alter/Alter.java | 15 +++++++++++++-- .../use_policy/alter_table_add_policy.groovy | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java index e506a1adc3..d3f188c46e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java @@ -52,9 +52,11 @@ import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.OlapTable.OlapTableState; import org.apache.doris.catalog.Partition; import org.apache.doris.catalog.PartitionInfo; +import org.apache.doris.catalog.Replica; import org.apache.doris.catalog.ReplicaAllocation; import org.apache.doris.catalog.Table; import org.apache.doris.catalog.TableIf.TableType; +import org.apache.doris.catalog.Tablet; import org.apache.doris.catalog.View; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.DdlException; @@ -187,8 +189,17 @@ public class Alter { if (currentAlterOps.checkTableStoragePolicy(alterClauses)) { String tableStoragePolicy = olapTable.getStoragePolicy(); if (!tableStoragePolicy.equals("")) { - throw new DdlException("Do not support alter table's storage policy , this table [" - + olapTable.getName() + "] has storage policy " + tableStoragePolicy); + for (Partition partition : olapTable.getAllPartitions()) { + for (Tablet tablet : partition.getBaseIndex().getTablets()) { + for (Replica replica : tablet.getReplicas()) { + if (replica.getRowCount() > 0 || replica.getDataSize() > 0) { + throw new DdlException("Do not support alter table's storage policy , this table [" + + olapTable.getName() + "] has storage policy " + tableStoragePolicy + + ", the table need to be empty."); + } + } + } + } } String currentStoragePolicy = currentAlterOps.getTableStoragePolicy(alterClauses); // check currentStoragePolicy resource exist. diff --git a/regression-test/suites/cold_heat_separation/use_policy/alter_table_add_policy.groovy b/regression-test/suites/cold_heat_separation/use_policy/alter_table_add_policy.groovy index 2963650903..bff146f6e0 100644 --- a/regression-test/suites/cold_heat_separation/use_policy/alter_table_add_policy.groovy +++ b/regression-test/suites/cold_heat_separation/use_policy/alter_table_add_policy.groovy @@ -83,8 +83,8 @@ suite("add_table_policy_by_alter_table") { def alter_table_when_table_has_storage_policy_result = try_sql """ ALTER TABLE create_table_not_have_policy set ("storage_policy" = "created_create_table_alter_policy"); """ - // errCode = 2, detailMessage = Do not support alter table's storage policy , this table [create_table_not_have_policy] has storage policy created_create_table_alter_policy - assertEquals(alter_table_when_table_has_storage_policy_result, null); + // OK + assertEquals(alter_table_when_table_has_storage_policy_result.size(), 1); if (!storage_exist.call("created_create_table_alter_policy_1")) { def create_s3_resource = try_sql """ @@ -113,8 +113,8 @@ suite("add_table_policy_by_alter_table") { def cannot_modify_exist_storage_policy_table_result = try_sql """ ALTER TABLE create_table_not_have_policy set ("storage_policy" = "created_create_table_alter_policy_1"); """ - // errCode = 2, detailMessage = Do not support alter table's storage policy , this table [create_table_not_have_policy] has storage policy created_create_table_alter_policy - assertEquals(cannot_modify_exist_storage_policy_table_result, null); + // OK + assertEquals(cannot_modify_exist_storage_policy_table_result.size(), 1); // you can change created_create_table_alter_policy's policy cooldown time, cooldown ttl property, // by alter storage policy --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org