[fix](bloom filter)Fix drop column with bloom filter (#41369) (#41711)

bp #41369
This commit is contained in:
qiye
2024-10-12 17:14:31 +08:00
committed by GitHub
parent 2ae37626bb
commit 203f00ef1d
3 changed files with 71 additions and 0 deletions

View File

@ -408,6 +408,18 @@ public class SchemaChangeHandler extends AlterHandler {
throw new DdlException("Column does not exists: " + dropColName);
}
// drop bloom filter column
Set<String> bfCols = olapTable.getCopiedBfColumns();
if (bfCols != null) {
Set<String> newBfCols = new HashSet<>();
for (String bfCol : bfCols) {
if (!bfCol.equalsIgnoreCase(dropColName)) {
newBfCols.add(bfCol);
}
}
olapTable.setBloomFilterInfo(newBfCols, olapTable.getBfFpp());
}
for (int i = 1; i < indexIds.size(); i++) {
List<Column> rollupSchema = indexSchemaMap.get(indexIds.get(i));
Iterator<Column> iter = rollupSchema.iterator();

View File

@ -0,0 +1,8 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
1 1
-- !select --
1 \N
2 \N

View File

@ -0,0 +1,51 @@
// 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_bloom_filter_drop_column") {
def table_name = "test_bloom_filter_drop_column"
sql """drop TABLE if exists ${table_name}"""
sql """CREATE TABLE IF NOT EXISTS ${table_name} (
`a` varchar(150) NULL,
`c1` varchar(10)
) ENGINE=OLAP
DUPLICATE KEY(`a`)
DISTRIBUTED BY HASH(`a`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"bloom_filter_columns" = "c1",
"in_memory" = "false",
"storage_format" = "V2"
)"""
sql """INSERT INTO ${table_name} values ('1', '1')"""
qt_select """select * from ${table_name} order by a"""
// drop column c1
sql """ALTER TABLE ${table_name} DROP COLUMN c1"""
// show create table
def res = sql """SHOW CREATE TABLE ${table_name}"""
assert res[0][1].contains("\"bloom_filter_columns\" = \"\"")
// add new column c1
sql """ALTER TABLE ${table_name} ADD COLUMN c1 ARRAY<STRING>"""
// insert data
sql """INSERT INTO ${table_name} values ('2', null)"""
// select data
qt_select """select * from ${table_name} order by a"""
}