csun5285 commented on code in PR #66472:
URL: https://github.com/apache/doris/pull/66472#discussion_r3764345113


##########
be/src/storage/tablet/tablet_reader.cpp:
##########
@@ -424,31 +320,29 @@ Status TabletReader::_init_orderby_keys_param(const 
ReaderParams& read_params) {
                         _tablet_schema->cluster_key_uids().size());
             }
             for (uint32_t i = 0; i < 
read_params.read_orderby_key_num_prefix_columns; i++) {
-                auto cid = _tablet_schema->cluster_key_uids()[i];
-                auto index = _tablet_schema->field_index(cid);
+                auto uid = _tablet_schema->cluster_key_uids()[i];
+                auto index = _tablet_schema->field_index(uid);
                 if (index < 0) {
                     return Status::Error<ErrorCode::INTERNAL_ERROR>(
                             "could not find cluster key column with 
unique_id=" +
-                            std::to_string(cid) +
+                            std::to_string(uid) +
                             " in tablet schema, tablet_id=" + 
std::to_string(_tablet->tablet_id()));
                 }
-                for (uint32_t idx = 0; idx < _return_columns.size(); idx++) {
-                    if (_return_columns[idx] == index) {
-                        _orderby_key_columns.push_back(idx);
-                        break;
-                    }
+                int32_t ordinal = 
_read_schema->ordinal_by_column(_tablet_schema->column(index));
+                if (ordinal < 0) {
+                    break; // size check below reports the error
                 }
+                _orderby_key_columns.push_back(ordinal);
             }
         } else {
-            // find index in vector _return_columns
-            //   for the read_orderby_key_num_prefix_columns orderby keys
+            // the orderby keys are the leading storage key columns; resolve
+            // each to its ordinal in the read schema
             for (uint32_t i = 0; i < 
read_params.read_orderby_key_num_prefix_columns; i++) {
-                for (uint32_t idx = 0; idx < _return_columns.size(); idx++) {
-                    if (_return_columns[idx] == i) {
-                        _orderby_key_columns.push_back(idx);
-                        break;
-                    }
+                int32_t ordinal = 
_read_schema->ordinal_by_column(_tablet_schema->column(i));
+                if (ordinal < 0) {
+                    break; // size check below reports the error

Review Comment:
   之前也没报错,按照找到key 的数量和read_orderby_key_num_prefix_columns 是否相等来报错的



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