This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new f030c430b35 [fix](schema change) fix the defineName field is not the
same when copying column (#34199) (#37470)
f030c430b35 is described below
commit f030c430b352973352681e7941e595c884e13cd0
Author: Luwei <[email protected]>
AuthorDate: Tue Jul 9 09:46:04 2024 +0800
[fix](schema change) fix the defineName field is not the same when copying
column (#34199) (#37470)
pick #34199
---------
Co-authored-by: Yongqiang YANG
<[email protected]>
---
.../main/java/org/apache/doris/catalog/Column.java | 8 +++-
.../schema_change_p0/test_add_rename_column.out | 6 +++
.../schema_change_p0/test_add_rename_column.groovy | 56 ++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
index 507fde9cec3..04de9348ef9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
@@ -243,7 +243,7 @@ public class Column implements Writable,
GsonPostProcessable {
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) {
@@ -287,6 +287,12 @@ public class Column implements Writable,
GsonPostProcessable {
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;
}
diff --git a/regression-test/data/schema_change_p0/test_add_rename_column.out
b/regression-test/data/schema_change_p0/test_add_rename_column.out
new file mode 100644
index 00000000000..edebb9dfd19
--- /dev/null
+++ b/regression-test/data/schema_change_p0/test_add_rename_column.out
@@ -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
+
diff --git
a/regression-test/suites/schema_change_p0/test_add_rename_column.groovy
b/regression-test/suites/schema_change_p0/test_add_rename_column.groovy
new file mode 100644
index 00000000000..f5f5363f738
--- /dev/null
+++ b/regression-test/suites/schema_change_p0/test_add_rename_column.groovy
@@ -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} """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]