You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2024/04/27 06:38:22 UTC
(doris) 30/30: [fix](schema change) fix the defineName field is not the same when copying column (#34199)
This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-4.0-preview
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 3b7c373589405128e27a0848f96451dcf238fd93
Author: Luwei <81...@qq.com>
AuthorDate: Sat Apr 27 13:51:48 2024 +0800
[fix](schema change) fix the defineName field is not the same when copying column (#34199)
---
.../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 82bac846d7d..a710cd340e6 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
@@ -288,7 +288,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();
this.hasOnUpdateDefaultValue = column.hasOnUpdateDefaultValue;
this.onUpdateDefaultValueExprDef = column.onUpdateDefaultValueExprDef;
this.clusterKeyId = column.getClusterKeyId();
@@ -335,6 +335,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..04f096d5707
--- /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: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org