Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions be/src/olap/delete_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,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>();
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions be/src/olap/delete_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class DeleteHandler {
// * 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(); }

Expand Down
5 changes: 1 addition & 4 deletions be/src/olap/tablet_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --

Original file line number Diff line number Diff line change
@@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use result = sql """ to get rid of empty .out file.

}