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

yiguolei 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 408dbf840b [bugfix](schema change) when there is a string column with 
delete predicate, the schema change may core (#11739)
408dbf840b is described below

commit 408dbf840bb67c6284f509b6c417b69324f23aaa
Author: yiguolei <676222...@qq.com>
AuthorDate: Fri Aug 12 19:29:22 2022 +0800

    [bugfix](schema change) when there is a string column with delete 
predicate, the schema change may core (#11739)
    
    * [bugfix](schema change) when there is a string column with delete 
predicate, the schema change may core
    
    Co-authored-by: yiguolei <yiguo...@gmail.com>
---
 be/src/olap/schema_change.cpp                      |  2 +-
 .../test_schema_change_with_delete.out             | 19 ++++++
 .../test_schema_change_with_delete.groovy          | 68 ++++++++++++++++++++++
 3 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index 28272d7572..0bccf7ea2d 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -1738,6 +1738,7 @@ Status 
SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
     }
 
     std::vector<Version> versions_to_be_changed;
+    vectorized::BlockReader reader;
     std::vector<RowsetReaderSharedPtr> rs_readers;
     // delete handlers for new tablet
     DeleteHandler delete_handler;
@@ -1849,7 +1850,6 @@ Status 
SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
                 break;
             }
 
-            vectorized::BlockReader reader;
             TabletReader::ReaderParams reader_params;
             reader_params.tablet = base_tablet;
             reader_params.reader_type = READER_ALTER_TABLE;
diff --git 
a/regression-test/data/schema_change/test_schema_change_with_delete.out 
b/regression-test/data/schema_change/test_schema_change_with_delete.out
new file mode 100644
index 0000000000..e74aa7504b
--- /dev/null
+++ b/regression-test/data/schema_change/test_schema_change_with_delete.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+2      2       2       bbb
+3      3       3       ccc
+
+-- !sql --
+2      2       2       bbb
+3      3       3       ccc
+
+-- !sql --
+2      2       2       bbb
+3      3       3       ccc
+4      4       efg     ddd
+
+-- !sql --
+2      2       2       bbb
+3      3       3       ccc
+4      4       efg     ddd
+
diff --git 
a/regression-test/suites/schema_change/test_schema_change_with_delete.groovy 
b/regression-test/suites/schema_change/test_schema_change_with_delete.groovy
new file mode 100644
index 0000000000..607f991f46
--- /dev/null
+++ b/regression-test/suites/schema_change/test_schema_change_with_delete.groovy
@@ -0,0 +1,68 @@
+// 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.
+
+// Test schema change for a table, the table has a delete predicate on string 
column
+suite("test_schema_change_with_delete") {
+
+    def tbName = "test_schema_change_with_delete"
+    def getJobState = { tableName ->
+          def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+          return jobStateResult[0][9]
+     }
+
+     sql """ DROP TABLE IF EXISTS ${tbName} FORCE"""
+     // Create table and disable light weight schema change
+     sql """
+            CREATE TABLE IF NOT EXISTS ${tbName}
+            (
+                event_day int,
+                siteid INT ,
+                citycode int,
+                username VARCHAR(32) DEFAULT ''
+            )
+            DUPLICATE  KEY(event_day,siteid)
+            DISTRIBUTED BY HASH(event_day) BUCKETS 1
+            PROPERTIES("replication_num" = "1", "light_schema_change" = 
"true"); 
+         """
+     sql """ insert into ${tbName} values(1, 1, 1, 'aaa');"""
+     sql """ insert into ${tbName} values(2, 2, 2, 'bbb');"""
+     sql """ delete from ${tbName} where username='aaa';"""
+     sql """ insert into ${tbName} values(3, 3, 3, 'ccc');"""
+
+    qt_sql """select /*+ SET_VAR(enable_vectorized_engine=true) */ * from 
${tbName};"""
+    qt_sql """select /*+ SET_VAR(enable_vectorized_engine=false) */ * from 
${tbName};"""
+
+    // Change column type to string
+    sql """ alter  table ${tbName} modify column citycode string """
+
+    int max_try_time = 1000
+    while(max_try_time--){
+          String result = getJobState(tbName)
+          if (result == "FINISHED") {
+               break
+          } else {
+               sleep(100)
+               if (max_try_time < 1){
+                    assertEquals(1,2)
+               }
+          }
+     }
+    sql """ insert into ${tbName} values(4, 4, 'efg', 'ddd');"""
+    qt_sql """select /*+ SET_VAR(enable_vectorized_engine=true) */ * from 
${tbName};"""
+    qt_sql """select /*+ SET_VAR(enable_vectorized_engine=false) */ * from 
${tbName};"""
+    sql """ DROP TABLE  ${tbName} force"""
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to