[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 <yiguolei@gmail.com>
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"""
|
||||
}
|
||||
Reference in New Issue
Block a user