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 0700449e8b8 [fix](schema change) fix delete predicate incorrect comparisons result with empty strings during schema change (#41064) (#42427) 0700449e8b8 is described below commit 0700449e8b8e24d0ef00bcbfd8c0b191e712d997 Author: Luwei <814383...@qq.com> AuthorDate: Fri Oct 25 01:05:55 2024 +0800 [fix](schema change) fix delete predicate incorrect comparisons result with empty strings during schema change (#41064) (#42427) ``` insert into t1 (k1, k2, v1) value(1, '', 2); delete form t1 where k1 = 1 and k2 = ''; alter table modify column v1 string select * from t1 // expect 0 rows in return, but get 1 row. ``` --- be/src/olap/delete_handler.cpp | 5 +- be/src/olap/delete_handler.h | 3 +- be/src/olap/tablet_reader.cpp | 5 +- .../schema_change_p0/test_schema_change_delete.out | 3 + .../test_schema_change_delete.groovy | 65 ++++++++++++++++++++++ 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp index 6145c986ee6..de7e1d1270e 100644 --- a/be/src/olap/delete_handler.cpp +++ b/be/src/olap/delete_handler.cpp @@ -386,8 +386,7 @@ template Status DeleteHandler::_parse_column_pred<std::string>( DeleteConditions* delete_conditions); Status DeleteHandler::init(TabletSchemaSPtr tablet_schema, - const std::vector<RowsetMetaSharedPtr>& delete_preds, int64_t version, - bool with_sub_pred_v2) { + const std::vector<RowsetMetaSharedPtr>& delete_preds, int64_t version) { DCHECK(!_is_inited) << "reinitialize delete handler."; DCHECK(version >= 0) << "invalid parameters. version=" << version; _predicate_arena = std::make_unique<vectorized::Arena>(); @@ -402,7 +401,7 @@ Status DeleteHandler::init(TabletSchemaSPtr tablet_schema, const auto& delete_condition = delete_pred->delete_predicate(); DeleteConditions temp; temp.filter_version = delete_pred->version().first; - if (with_sub_pred_v2 && !delete_condition.sub_predicates_v2().empty()) { + if (!delete_condition.sub_predicates_v2().empty()) { RETURN_IF_ERROR(_parse_column_pred(tablet_schema, delete_pred_related_schema, delete_condition.sub_predicates_v2(), &temp)); } else { diff --git a/be/src/olap/delete_handler.h b/be/src/olap/delete_handler.h index a2b38cd1548..c4632c4a68a 100644 --- a/be/src/olap/delete_handler.h +++ b/be/src/olap/delete_handler.h @@ -104,8 +104,7 @@ public: // * Status::Error<DELETE_INVALID_PARAMETERS>(): input parameters are not valid // * Status::Error<MEM_ALLOC_FAILED>(): alloc memory failed Status init(TabletSchemaSPtr tablet_schema, - const std::vector<RowsetMetaSharedPtr>& delete_preds, int64_t version, - bool with_sub_pred_v2 = false); + const std::vector<RowsetMetaSharedPtr>& delete_preds, int64_t version); [[nodiscard]] bool empty() const { return _del_conds.empty(); } diff --git a/be/src/olap/tablet_reader.cpp b/be/src/olap/tablet_reader.cpp index 3c6ecbea6e1..469da277967 100644 --- a/be/src/olap/tablet_reader.cpp +++ b/be/src/olap/tablet_reader.cpp @@ -625,11 +625,8 @@ Status TabletReader::_init_delete_condition(const ReaderParams& read_params) { ((read_params.reader_type == ReaderType::READER_CUMULATIVE_COMPACTION && config::enable_delete_when_cumu_compaction)) || read_params.reader_type == ReaderType::READER_CHECKSUM); - auto* runtime_state = read_params.runtime_state; - bool enable_sub_pred_v2 = - runtime_state == nullptr ? true : runtime_state->enable_delete_sub_pred_v2(); return _delete_handler.init(_tablet_schema, read_params.delete_predicates, - read_params.version.second, enable_sub_pred_v2); + read_params.version.second); } Status TabletReader::init_reader_params_and_create_block( diff --git a/regression-test/data/schema_change_p0/test_schema_change_delete.out b/regression-test/data/schema_change_p0/test_schema_change_delete.out new file mode 100644 index 00000000000..f958424e65c --- /dev/null +++ b/regression-test/data/schema_change_p0/test_schema_change_delete.out @@ -0,0 +1,3 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- + diff --git a/regression-test/suites/schema_change_p0/test_schema_change_delete.groovy b/regression-test/suites/schema_change_p0/test_schema_change_delete.groovy new file mode 100644 index 00000000000..873cf2d4c0a --- /dev/null +++ b/regression-test/suites/schema_change_p0/test_schema_change_delete.groovy @@ -0,0 +1,65 @@ +// 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. + +// The cases is copied from https://github.com/trinodb/trino/tree/master +// /testing/trino-product-tests/src/main/resources/sql-tests/testcases +// and modified by Doris. + +suite("test_schema_change_delete") { + def tableName = "sc_delete_tbl" + + sql """ DROP TABLE IF EXISTS ${tableName} """ + + sql """ + CREATE TABLE ${tableName} ( + `col1` tinyint NOT NULL, + `col2` varchar(11) NOT NULL, + `col3` date NOT NULL, + `col5` int REPLACE NOT NULL, + `col4` date REPLACE NOT NULL, + `col6` float REPLACE_IF_NOT_NULL NULL + ) ENGINE=OLAP + AGGREGATE KEY(`col1`, `col2`, `col3`) + DISTRIBUTED BY HASH(`col1`, `col2`, `col3`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "min_load_replica_num" = "-1", + "is_being_synced" = "false", + "storage_medium" = "hdd", + "storage_format" = "V2", + "inverted_index_storage_format" = "V2", + "light_schema_change" = "true", + "disable_auto_compaction" = "true", + "enable_single_replica_compaction" = "false", + "group_commit_interval_ms" = "10000", + "group_commit_data_bytes" = "134217728" + ) + """ + + sql """ insert into ${tableName} values (-100, '', '2023-10-19', -72, '2024-01-01', '1.1'); """ + + sql """ delete from ${tableName} where col1 = -100 and col2 = '' and col3 = '2023-10-19' """ + + sql """ alter table ${tableName} MODIFY COLUMN `col5` string REPLACE NOT NULL """ + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ + time 600 + } + + qt_select "select * from ${tableName}" +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org