dxyou0830 commented on code in PR #70585:
URL: https://github.com/apache/doris/pull/70585#discussion_r4577681465


##########
be/src/cloud/cloud_snapshot_mgr.cpp:
##########
@@ -304,15 +304,18 @@ Status 
CloudSnapshotMgr::_rename_index_ids(TabletSchemaPB& schema_pb,
         return Status::OK();
     }
 
-    for (int i = 0; i < schema_pb.index_size(); ++i) {
-        TabletIndexPB* index_pb = schema_pb.mutable_index(i);
-        for (int32_t col_unique_id : index_pb->col_unique_id()) {
-            auto local_index = tablet_schema->get_index(col_unique_id, 
index_pb->index_type(),
-                                                        
index_pb->index_suffix_name());
-            if (local_index) {
-                if (index_pb->index_id() != local_index->index_id()) {
-                    index_pb->set_index_id(local_index->index_id());
-                }
+    TabletSchemaPB target_schema_pb;
+    tablet_schema->to_schema_pb(&target_schema_pb);
+    for (auto& index_pb : *schema_pb.mutable_index()) {
+        TabletIndex source_index;
+        source_index.init_from_pb(index_pb);
+        for (const auto& target_index_pb : target_schema_pb.index()) {
+            TabletIndex target_index;
+            target_index.init_from_pb(target_index_pb);
+            // An exact index and a normalizer index can share column, type 
and suffix.
+            // Match their names and definitions instead of selecting the 
first index.
+            if (source_index.is_same_except_id(&target_index)) {
+                index_pb.set_index_id(target_index.index_id());

Review Comment:
   Thanks, this partial-match case does produce duplicate identities. Both 
remapping paths now validate the complete assignment, including retained source 
IDs, before updating the schema. For a colliding unmatched index, the legacy 
column/type/suffix lookup is used only when its target identity is unoccupied; 
your example therefore maps to 1002/1003. Any remaining collision returns an 
explicit error without partially modifying the input schema. Same-tablet clone 
behavior is unchanged.
   
   Added local and cloud coverage for overlapping IDs, reversed source/target 
order, missing or occupied fallback targets, and equal IDs with different 
suffixes. clang-format 16, diff whitespace checks and build-hygiene checks 
pass. Master compilation, unit tests and clang-tidy remain pending upstream CI.
   
   ### AI Disclosure
   
   - Tool: OpenAI Codex (GPT-6) for code, tests and description; reviewed by 
Anthropic Claude.
   - Generated: Code, tests and this description.
   - Human review: Reviewed by dxyou0830 (submitter).
   



-- 
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]

Reply via email to