Skip to content

Commit

Permalink
[fix](schema-change) Fix single column table could not rename columns (
Browse files Browse the repository at this point in the history
…apache#47275)

Single column tables was not able to rename column due to light schema
change check in error way.
  • Loading branch information
TangSiyang2001 authored Jan 24, 2025
1 parent e1760a8 commit 1d34eae
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -5126,8 +5126,8 @@ private void renameColumn(Database db, OlapTable table, String colName,

Map<Long, MaterializedIndexMeta> indexIdToMeta = table.getIndexIdToMeta();
for (Map.Entry<Long, MaterializedIndexMeta> entry : indexIdToMeta.entrySet()) {
// rename column is not implemented for table without column unique id.
if (entry.getValue().getMaxColUniqueId() <= 0) {
// rename column is not implemented for non-light-schema-change table.
if (!table.getEnableLightSchemaChange()) {
throw new DdlException("not implemented for table without column unique id,"
+ " which are created with property 'light_schema_change'.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !desc --
test_rename_single_col_tbl DUP_KEYS rename_partition_col DATE datev2 No true \N true

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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_rename_single_col_tbl") {
def tblName = "test_rename_single_col_tbl"
sql """ DROP TABLE IF EXISTS ${tblName} """
sql """
CREATE TABLE ${tblName}
(
col0 DATE NOT NULL,
)
DUPLICATE KEY(col0)
DISTRIBUTED BY HASH(col0) BUCKETS 4
PROPERTIES (
"replication_num" = "1"
);
"""
sql """
ALTER TABLE ${tblName} RENAME COLUMN col0 rename_partition_col
"""
sql """ SYNC """
qt_desc """ DESC ${tblName} ALL """
}

0 comments on commit 1d34eae

Please sign in to comment.