From dc706ed49b5d1b45d45ea58e78d39de011c18bc5 Mon Sep 17 00:00:00 2001 From: camby Date: Mon, 9 Sep 2024 10:20:55 +0900 Subject: [PATCH] [fix](delete_predicate) fix wrong data after upgrade from v2.0 version (#40401) issue: https://github.com/apache/doris/issues/40390 related pr: https://github.com/apache/doris/pull/22442 --- be/src/olap/delete_handler.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp index 10c6f50b30098d..2f4e77d036b29c 100644 --- a/be/src/olap/delete_handler.cpp +++ b/be/src/olap/delete_handler.cpp @@ -411,7 +411,20 @@ Status DeleteHandler::init(TabletSchemaSPtr tablet_schema, for (const auto& in_predicate : delete_condition.in_predicates()) { TCondition condition; condition.__set_column_name(in_predicate.column_name()); - auto col_unique_id = in_predicate.column_unique_id(); + + int32_t col_unique_id = -1; + if (in_predicate.has_column_unique_id()) { + col_unique_id = in_predicate.column_unique_id(); + } else { + // if upgrade from version 2.0.x, column_unique_id maybe not set + const auto& pre_column = + *DORIS_TRY(delete_pred_related_schema->column(condition.column_name)); + col_unique_id = pre_column.unique_id(); + } + if (col_unique_id == -1) { + return Status::Error( + "cannot get column_unique_id for column {}", condition.column_name); + } condition.__set_column_unique_id(col_unique_id); if (in_predicate.is_not_in()) {