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
commit 26d5c503394d7a5d38178f41cecbe51af19556d4 Author: lihangyu <15605149...@163.com> AuthorDate: Sun May 19 20:47:10 2024 +0800 [Bug](Variant) fix incorrect use of column index in TabletSchema (#35019) --- be/src/vec/common/schema_util.cpp | 4 +- .../test_alter_add_drop_column.groovy | 53 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/be/src/vec/common/schema_util.cpp b/be/src/vec/common/schema_util.cpp index 2f9e5ded212..49e901e0846 100644 --- a/be/src/vec/common/schema_util.cpp +++ b/be/src/vec/common/schema_util.cpp @@ -395,9 +395,9 @@ void inherit_root_attributes(TabletSchemaSPtr& schema) { col.type() != FieldType::OLAP_FIELD_TYPE_DOUBLE && col.type() != FieldType::OLAP_FIELD_TYPE_FLOAT) { // above types are not supported in bf - col.set_is_bf_column(schema->column(col.parent_unique_id()).is_bf_column()); + col.set_is_bf_column(schema->column_by_uid(col.parent_unique_id()).is_bf_column()); } - col.set_aggregation_method(schema->column(col.parent_unique_id()).aggregation()); + col.set_aggregation_method(schema->column_by_uid(col.parent_unique_id()).aggregation()); auto it = variants_index_meta.find(col.parent_unique_id()); // variant has no index meta, ignore if (it == variants_index_meta.end()) { diff --git a/regression-test/suites/variant_p0/schema_change/test_alter_add_drop_column.groovy b/regression-test/suites/variant_p0/schema_change/test_alter_add_drop_column.groovy new file mode 100644 index 00000000000..6a38ec2804e --- /dev/null +++ b/regression-test/suites/variant_p0/schema_change/test_alter_add_drop_column.groovy @@ -0,0 +1,53 @@ +// 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("regression_test_variant_add_drop_column", "variant_type"){ + def table_name = "variant_add_drop_column" + sql "DROP TABLE IF EXISTS ${table_name}" + sql """ + CREATE TABLE IF NOT EXISTS ${table_name} ( + k bigint, + v variant + ) + DUPLICATE KEY(`k`) + DISTRIBUTED BY HASH(k) BUCKETS 1 + properties("replication_num" = "1", "bloom_filter_columns" = "v"); + """ + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}')""" + + sql "alter table variant_add_drop_column add column v2 variant default null" + sql "alter table variant_add_drop_column add column t1 datetime default null" + sql "alter table variant_add_drop_column add column t2 datetime default null" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345234567,"b" : 2}', '{"xxx" : 1}', "2021-01-01 01:01:01", "2021-01-01 01:01:01")""" + sql "alter table variant_add_drop_column add column i1 int default null" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}', '{"xxx" : 1}', "2021-01-01 01:01:01", "2021-01-01 01:01:01", 12345)""" + sql "alter table variant_add_drop_column drop column t1" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}', '{"xxx" : 1}', "2021-01-01 01:01:01", 12345)""" + sql "alter table variant_add_drop_column drop column t2" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}', '{"xxx" : 1}', 12345)""" + sql "alter table variant_add_drop_column drop column i1" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}', '{"xxx" : 1}')""" + sql "alter table variant_add_drop_column drop column v" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}')""" + sql "alter table variant_add_drop_column add column v variant default null" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}', '{"a" : 12345,"b" : 2}')""" + sql "alter table variant_add_drop_column add column v3 variant default null" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}', '{"a" : 12345,"b" : 2}', '{"a" : 12345,"b" : 2}')""" + sql "alter table variant_add_drop_column drop column v" + sql "alter table variant_add_drop_column drop column v2" + sql """insert into variant_add_drop_column values (1, '{"a" : 12345,"b" : 2}')""" +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org