diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java index 1d9fd18e3d..7013e1a961 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java @@ -466,6 +466,9 @@ public class SchemaChangeHandler extends AlterHandler { throw new DdlException("Column does not exists: " + dropColName); } } + if (olapTable.isDistributionColumn(dropColName)) { + throw new DdlException("Could not drop distribution column: " + dropColName); + } return lightSchemaChange; } diff --git a/regression-test/suites/partition_p0/multi_partition/test_multi_column_partition.groovy b/regression-test/suites/partition_p0/multi_partition/test_multi_column_partition.groovy index 0f4c41bc7f..7b8aa7b425 100644 --- a/regression-test/suites/partition_p0/multi_partition/test_multi_column_partition.groovy +++ b/regression-test/suites/partition_p0/multi_partition/test_multi_column_partition.groovy @@ -328,7 +328,7 @@ suite("test_multi_partition_key", "p0") { assertEquals("FINISHED", getAlterColumnFinalState("test_multi_column_drop_partition_column")) test { sql "ALTER TABLE test_multi_column_drop_partition_column DROP COLUMN k1" - exception "Partition column[k1] cannot be dropped" + exception "Could not drop distribution column: k1" } sql "insert into test_multi_column_drop_partition_column " + "values(100, 0, 0, 0, 0, '2000-01-01 00:00:00', 0.001, -0.001, 0.001)" diff --git a/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy b/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy index 163f1267aa..a42588a80e 100644 --- a/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy +++ b/regression-test/suites/schema_change_p0/test_alter_table_drop_column.groovy @@ -171,7 +171,7 @@ suite("test_alter_table_drop_column") { test { sql """alter table ${dupTableName} drop COLUMN siteid;""" // check exception message contains - exception "Distribution column[siteid] cannot be dropped" + exception "Could not drop distribution column: siteid" } sql "DROP TABLE IF EXISTS ${dupTableName} FORCE" diff --git a/regression-test/suites/schema_change_p0/test_disable_drop_bucket_columns.groovy b/regression-test/suites/schema_change_p0/test_disable_drop_bucket_columns.groovy new file mode 100644 index 0000000000..578d792caf --- /dev/null +++ b/regression-test/suites/schema_change_p0/test_disable_drop_bucket_columns.groovy @@ -0,0 +1,43 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_disable_drop_bucket_columns") { + def tables = ["test_disable_drop_bucket_columns_dup", "test_disable_drop_bucket_columns_agg"] + def keys = ["DUPLICATE KEY(k1, k2)", "AGGREGATE KEY(k1, k2)"] + def aggTypes = ["", "SUM"] + for (i in 0..