Skip to content

Commit

Permalink
[fix](schema change) fix the defineName field is not the same when co…
Browse files Browse the repository at this point in the history
…pying column (apache#34199) (apache#37470)

pick apache#34199

---------

Co-authored-by: Yongqiang YANG <98214048+dataroaring@users.noreply.github.com>
  • Loading branch information
luwei16 and dataroaring authored Jul 9, 2024
1 parent 6a5c2a7 commit f030c43
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public Column(Column column) {
this.children = column.getChildren();
this.uniqueId = column.getUniqueId();
this.defineExpr = column.getDefineExpr();
this.defineName = column.getDefineName();
this.defineName = column.getRealDefineName();
}

public void createChildrenColumn(Type type, Column column) {
Expand Down Expand Up @@ -287,6 +287,12 @@ public String getDefineName() {
return name;
}

// In order for the copy constructor to get the real defineName value.
// getDefineName() cannot meet this requirement
public String getRealDefineName() {
return defineName;
}

public void setName(String newName) {
this.name = newName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --

-- !sql --
3 cc dd

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.

// The cases is copied from https://github.com/trinodb/trino/tree/master
// /testing/trino-product-tests/src/main/resources/sql-tests/testcases
// and modified by Doris.

suite("test_add_rename_column") {
def tableName = "test_add_rename"

sql """ DROP TABLE IF EXISTS ${tableName} """

sql """
create table ${tableName}(
id int,
name varchar(100)
) ENGINE = olap
unique key(id)
distributed by hash(id) buckets 1
properties (
'replication_num' = '1'
)
"""

sql """ insert into ${tableName} values (2, 'bb') """

sql """ ALTER TABLE ${tableName} add column c3 varchar(10) """

sql """ ALTER TABLE ${tableName} rename column c3 c4 """

sql """ truncate table ${tableName} """

sql """ sync """

qt_sql """ select * from ${tableName} """

sql """ insert into ${tableName} values (3, 'cc', 'dd') """

sql """ sync """

qt_sql """ select * from ${tableName} """
}

0 comments on commit f030c43

Please sign in to comment.