yiguolei commented on code in PR #66472:
URL: https://github.com/apache/doris/pull/66472#discussion_r3747247429
##########
be/src/storage/delete/delete_handler.cpp:
##########
@@ -535,45 +535,80 @@ Status DeleteHandler::_parse_column_pred(TabletSchemaSPtr
complete_schema,
col_unique_id = sub_predicate.column_unique_id();
}
}
- if (col_unique_id < 0) {
- const auto& column =
-
*DORIS_TRY(delete_pred_related_schema->column(condition.column_name));
- col_unique_id = column.unique_id();
- }
- condition.col_unique_id = col_unique_id;
- const auto& column = complete_schema->column_by_uid(col_unique_id);
- uint32_t index = complete_schema->field_index(col_unique_id);
+ ColumnId column_id;
+ RETURN_IF_ERROR(_resolve_column(read_schema, col_unique_id,
condition.column_name,
+ delete_pred_related_schema,
&column_id));
+ const auto& column = *read_schema.column(column_id);
+ condition.col_unique_id = column.unique_id();
std::shared_ptr<ColumnPredicate> predicate;
- RETURN_IF_ERROR(parse_to_predicate(index, column.name(),
column.get_vec_type(), condition,
- _predicate_arena, predicate));
+ RETURN_IF_ERROR(parse_to_predicate(column_id, column.name(),
column.get_vec_type(),
+ condition, _predicate_arena,
predicate));
if (predicate != nullptr) {
delete_conditions->column_predicate_vec.push_back(predicate);
}
}
return Status::OK();
}
-Status DeleteHandler::init(TabletSchemaSPtr tablet_schema,
+Status DeleteHandler::_resolve_column(ReadSchema& read_schema, int32_t
col_unique_id,
+ const std::string& column_name,
+ const TabletSchemaSPtr&
delete_pred_related_schema,
+ ColumnId* column_id) {
+ // A valid UID is the complete identity. A dropped column and a later
+ // same-name replacement must remain distinct.
+ if (col_unique_id >= 0) {
+ int32_t ordinal = read_schema.ordinal_by_uid(col_unique_id);
+ if (ordinal >= 0) {
+ *column_id = ordinal;
+ return Status::OK();
+ }
+ }
+
+ int32_t rowset_schema_ordinal = -1;
+ if (col_unique_id >= 0) {
+ rowset_schema_ordinal =
delete_pred_related_schema->field_index(col_unique_id);
+ } else {
+ rowset_schema_ordinal =
delete_pred_related_schema->field_index(column_name);
+ }
+ if (rowset_schema_ordinal < 0) {
+ return Status::Error<ErrorCode::DELETE_INVALID_CONDITION>(
+ "cannot find delete predicate column name={} unique_id={} in
rowset schema",
+ column_name, col_unique_id);
+ }
+
+ const auto& historical_column =
delete_pred_related_schema->columns()[rowset_schema_ordinal];
+ int32_t ordinal = read_schema.ordinal_by_column(*historical_column);
+ if (ordinal >= 0) {
+ *column_id = ordinal;
+ return Status::OK();
+ }
+
+ *column_id = read_schema.append_column(historical_column);
+ return Status::OK();
+}
+
+Status DeleteHandler::init(ReadSchemaSPtr& read_schema,
const std::vector<RowsetMetaSharedPtr>&
delete_preds, int64_t version) {
DCHECK(!_is_inited) << "reinitialize delete handler.";
DCHECK(version >= 0) << "invalid parameters. version=" << version;
+ ReadSchema extended_read_schema = *read_schema;
Review Comment:
这里copy 一下的目的是什么?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]