This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 203f00ef1dc [fix](bloom filter)Fix drop column with bloom filter
(#41369) (#41711)
203f00ef1dc is described below
commit 203f00ef1dcc2aabf2fb60fac7029ca1ff4065ad
Author: qiye <[email protected]>
AuthorDate: Sat Oct 12 17:14:31 2024 +0800
[fix](bloom filter)Fix drop column with bloom filter (#41369) (#41711)
bp #41369
---
.../apache/doris/alter/SchemaChangeHandler.java | 12 +++++
.../test_bloom_filter_drop_column.out | 8 ++++
.../test_bloom_filter_drop_column.groovy | 51 ++++++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index 3cc199633f9..73a4865c4b6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -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();
diff --git
a/regression-test/data/bloom_filter_p0/test_bloom_filter_drop_column.out
b/regression-test/data/bloom_filter_p0/test_bloom_filter_drop_column.out
new file mode 100644
index 00000000000..2c6ca8d224b
--- /dev/null
+++ b/regression-test/data/bloom_filter_p0/test_bloom_filter_drop_column.out
@@ -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
+
diff --git
a/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy
b/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy
new file mode 100644
index 00000000000..a18ff9fdbe0
--- /dev/null
+++
b/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy
@@ -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"""
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]