This is an automated email from the ASF dual-hosted git repository. gavinchou pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit a284feb2c9d1fd1f8254ac1a7a403487c4368413 Author: Siyang Tang <82279870+tangsiyang2...@users.noreply.github.com> AuthorDate: Fri Sep 6 00:09:23 2024 +0800 [fix](cloud-schema-change) Exclude merged dropped columns from projection columns (#40187) ## Proposed changes schema change in cloud mode used to merge dropped columns from delete predicates to projection columns when reading data from base tablet, resulted in failure when reading rowsets after columns dropped. --- be/src/cloud/cloud_schema_change_job.cpp | 8 ++-- .../test_merge_dropped_column.groovy | 47 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/be/src/cloud/cloud_schema_change_job.cpp b/be/src/cloud/cloud_schema_change_job.cpp index 254a0d8d966..acab3aa80ad 100644 --- a/be/src/cloud/cloud_schema_change_job.cpp +++ b/be/src/cloud/cloud_schema_change_job.cpp @@ -100,6 +100,10 @@ Status CloudSchemaChangeJob::process_alter_tablet(const TAlterTabletReqV2& reque _base_tablet_schema->update_tablet_columns(*_base_tablet->tablet_schema(), request.columns); _new_tablet_schema = _new_tablet->tablet_schema(); + std::vector<ColumnId> return_columns; + return_columns.resize(_base_tablet_schema->num_columns()); + std::iota(return_columns.begin(), return_columns.end(), 0); + // delete handlers to filter out deleted rows DeleteHandler delete_handler; std::vector<RowsetMetaSharedPtr> delete_predicates; @@ -112,10 +116,6 @@ Status CloudSchemaChangeJob::process_alter_tablet(const TAlterTabletReqV2& reque } RETURN_IF_ERROR(delete_handler.init(_base_tablet_schema, delete_predicates, base_max_version)); - std::vector<ColumnId> return_columns; - return_columns.resize(_base_tablet_schema->num_columns()); - std::iota(return_columns.begin(), return_columns.end(), 0); - // reader_context is stack variables, it's lifetime MUST keep the same with rs_readers RowsetReaderContext reader_context; reader_context.reader_type = ReaderType::READER_ALTER_TABLE; diff --git a/regression-test/suites/schema_change_p0/test_merge_dropped_column.groovy b/regression-test/suites/schema_change_p0/test_merge_dropped_column.groovy new file mode 100644 index 00000000000..40aed871e76 --- /dev/null +++ b/regression-test/suites/schema_change_p0/test_merge_dropped_column.groovy @@ -0,0 +1,47 @@ +// 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_merge_dropped_column") { + def tableName = "test_merge_dropped_column" + sql """ drop table if exists ${tableName} """ + sql """ create table ${tableName} + ( + col1 SMALLINT NOT NULL, + col2 BIGINT NOT NULL, + col3 TEXT NOT NULL, + col4 FLOAT NOT NULL, + col5 TINYINT NOT NULL + ) DUPLICATE KEY(`col1`) DISTRIBUTED BY HASH (`col1`) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction"="true", + "replication_num" = "1" + ); + """ + sql """ INSERT INTO ${tableName} VALUES(5, 6, "wwwe", 1.2, 3) """ + sql """ DELETE FROM ${tableName} WHERE col1 = 0 """ + + sql """ ALTER TABLE ${tableName} DROP COLUMN col3 """ + sql """ INSERT INTO ${tableName} VALUES(7, 1212, 2.22, 2) """ + // sql """ ALTER TABLE ${tableName} ADD COLUMN col3 TEXT NOT DEFAULT NULL """ + + sql """ ALTER TABLE ${tableName} MODIFY COLUMN col2 TEXT NOT NULL""" + + waitForSchemaChangeDone { + sql """SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1""" + time 600 + } +} \ 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