[fix](schema-change) Forbid dropping distribution columns (branch-2.1) (#54039)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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)"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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..<tables.size()) {
|
||||
def tbl = tables.get(i)
|
||||
def key = keys.get(i)
|
||||
def aggType = aggTypes.get(i)
|
||||
sql """ DROP TABLE IF EXISTS ${tbl} """
|
||||
sql """
|
||||
CREATE TABLE IF NOT EXISTS ${tbl}
|
||||
(
|
||||
k1 DATE,
|
||||
k2 INT DEFAULT '10',
|
||||
v INT ${aggType}
|
||||
) ${key}
|
||||
DISTRIBUTED BY HASH(k1, k2) BUCKETS 5
|
||||
PROPERTIES("replication_num" = "1", "light_schema_change" = "true");
|
||||
"""
|
||||
|
||||
test {
|
||||
sql """ ALTER TABLE ${tbl} DROP COLUMN k2"""
|
||||
exception "Could not drop distribution column"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -492,7 +492,7 @@ suite("test_schema_reordering_dup", "p0") {
|
||||
" (3, 'Mike Johnson', 77.8, 'Chicago', 35, 1, 1112223334, true, 30, 3000000000, '2024-06-13', '2024-06-13', '2024-06-13 11:15:00', '2024-06-13 11:15:00', 'Test String 3', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]',95.5, 9.99)," +
|
||||
" (4, 'Emily Brown', 92.0, 'San Francisco', 28, 2, 5556667778, true, 40, 4000000000, '2024-06-14', '2024-06-14', '2024-06-14 13:30:00', '2024-06-14 13:30:00', 'Test String 4', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]',95.5, 9.99)," +
|
||||
" (5, 'David Wilson', 88.9, 'Seattle', 32, 1, 9998887776, false, 50, 5000000000, '2024-06-15', '2024-06-15', '2024-06-15 15:45:00', '2024-06-15 15:45:00', 'Test String 5', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]',95.5, 9.99);"
|
||||
errorMessage = "errCode = 2, detailMessage = Table regression_test_schema_change_p0.test_schema_reordering_dup check failed"
|
||||
errorMessage = "errCode = 2, detailMessage = Could not drop distribution column: username"
|
||||
expectException({
|
||||
sql initTable
|
||||
sql initTableData
|
||||
|
||||
Reference in New Issue
Block a user