diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp index 2f4e77d036b29c..4d5b1ce9add3e0 100644 --- a/be/src/olap/delete_handler.cpp +++ b/be/src/olap/delete_handler.cpp @@ -384,8 +384,7 @@ template Status DeleteHandler::_parse_column_pred( DeleteConditions* delete_conditions); Status DeleteHandler::init(TabletSchemaSPtr tablet_schema, - const std::vector& delete_preds, int64_t version, - bool with_sub_pred_v2) { + const std::vector& delete_preds, int64_t version) { DCHECK(!_is_inited) << "reinitialize delete handler."; DCHECK(version >= 0) << "invalid parameters. version=" << version; _predicate_arena = std::make_unique(); @@ -400,7 +399,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 0910795a81cc35..cc585c0abcf9f6 100644 --- a/be/src/olap/delete_handler.h +++ b/be/src/olap/delete_handler.h @@ -104,8 +104,7 @@ class DeleteHandler { // * Status::Error(): input parameters are not valid // * Status::Error(): alloc memory failed Status init(TabletSchemaSPtr tablet_schema, - const std::vector& delete_preds, int64_t version, - bool with_sub_pred_v2 = false); + const std::vector& 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 dcdd8819e3d05d..9ab9e4b1b365f5 100644 --- a/be/src/olap/tablet_reader.cpp +++ b/be/src/olap/tablet_reader.cpp @@ -635,11 +635,8 @@ Status TabletReader::_init_delete_condition(const ReaderParams& read_params) { // However, queries will not use this condition but generate special where predicates to filter data. // (Though a lille bit confused, it is how the current logic working...) _filter_delete = _delete_sign_available || cumu_delete; - 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 00000000000000..f958424e65c626 --- /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 00000000000000..873cf2d4c0a9cb --- /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}" +}