This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a324bc9fe3 [Fix](schema change) Fix NPE when rename column on table 
which has sequence type column (#46906)
9a324bc9fe3 is described below

commit 9a324bc9fe3fef48dc7442d8306062edf54a1db4
Author: bobhan1 <[email protected]>
AuthorDate: Tue Jan 14 09:46:47 2025 +0800

    [Fix](schema change) Fix NPE when rename column on table which has sequence 
type column (#46906)
    
    ### What problem does this PR solve?
    Problem Summary:
    ```mysql
    CREATE TABLE `tbl` (
      `c` tinyint NULL,
    ) ENGINE=OLAP
    UNIQUE KEY(`c`)
    DISTRIBUTED BY HASH(`c`) BUCKETS 10
    PROPERTIES (
      "function_column.sequence_type" = "bigint"
    );
    
    mysql> alter table tbl rename column c c_bk;
    ERROR 1105 (HY000): errCode = 2, detailMessage = Cannot invoke 
"String.equalsIgnoreCase(String)" because the return value of 
"org.apache.doris.catalog.OlapTable.getSequenceMapCol()" is null
    ```
---
 .../main/java/org/apache/doris/catalog/Env.java    |  3 +-
 .../test_seq_type_rename_col.out                   | 17 +++++++++
 .../test_seq_type_rename_col.groovy                | 44 ++++++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 7e0617a84a0..06968138cc8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -5225,7 +5225,8 @@ public class Env {
         }
 
         // 5. modify sequence map col
-        if (table.hasSequenceCol() && 
table.getSequenceMapCol().equalsIgnoreCase(colName)) {
+        if (table.hasSequenceCol() && table.getSequenceMapCol() != null
+                && table.getSequenceMapCol().equalsIgnoreCase(colName)) {
             table.setSequenceMapCol(newColName);
         }
 
diff --git 
a/regression-test/data/unique_with_mow_p0/test_seq_type_rename_col.out 
b/regression-test/data/unique_with_mow_p0/test_seq_type_rename_col.out
new file mode 100644
index 00000000000..5c2a2741d41
--- /dev/null
+++ b/regression-test/data/unique_with_mow_p0/test_seq_type_rename_col.out
@@ -0,0 +1,17 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      1       1
+2      2       2
+3      3       3
+4      4       4
+5      5       5
+6      6       6
+
+-- !sql --
+1      1       1
+2      2       2
+3      3       3
+4      4       4
+5      5       5
+6      6       6
+
diff --git 
a/regression-test/suites/unique_with_mow_p0/test_seq_type_rename_col.groovy 
b/regression-test/suites/unique_with_mow_p0/test_seq_type_rename_col.groovy
new file mode 100644
index 00000000000..1659a3be0c9
--- /dev/null
+++ b/regression-test/suites/unique_with_mow_p0/test_seq_type_rename_col.groovy
@@ -0,0 +1,44 @@
+
+// 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_seq_type_rename_col", "p0") {
+
+    def table1 = "test_seq_type_rename_col"
+    sql "DROP TABLE IF EXISTS ${table1} FORCE;"
+    sql """ CREATE TABLE IF NOT EXISTS ${table1} (
+            `k1` int NOT NULL,
+            `c1` int,
+            `c2` int,
+        )UNIQUE KEY(k1)
+        DISTRIBUTED BY HASH(k1) BUCKETS 1
+        PROPERTIES (
+            "enable_mow_light_delete" = "false",
+            "function_column.sequence_type" = "bigint",
+            "disable_auto_compaction" = "true",
+            "replication_num" = "1"); """
+
+    sql "insert into ${table1}(k1,c1,c2,__DORIS_SEQUENCE_COL__) 
values(1,1,1,1),(2,2,2,2),(3,3,3,3);"
+    sql "insert into ${table1}(k1,c1,c2,__DORIS_SEQUENCE_COL__) 
values(4,4,4,4),(5,5,5,5),(6,6,6,6);"
+    sql "sync;"
+    qt_sql "select * from ${table1} order by k1;"
+
+    sql "alter table ${table1} rename column c1 c1_rename;"
+    
+
+    qt_sql "select * from ${table1} order by k1;"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to