HappenLee commented on code in PR #23236:
URL: https://github.com/apache/doris/pull/23236#discussion_r1308145522


##########
be/src/exec/tablet_info.cpp:
##########
@@ -457,4 +475,54 @@ Status 
VOlapTablePartitionParam::_create_partition_key(const TExprNode& t_expr,
     return Status::OK();
 }
 
+Status VOlapTablePartitionParam::add_partitions(
+        const std::vector<TOlapTablePartition>& partitions) {
+    for (const auto& t_part : partitions) {
+        auto part = _obj_pool.add(new VOlapTablePartition(&_partition_block));
+        part->id = t_part.id;
+        part->is_mutable = t_part.is_mutable;
+
+        // for auto partitions, so range partition only
+        if (t_part.__isset.start_keys) {
+            RETURN_IF_ERROR(_create_partition_keys(t_part.start_keys, 
&part->start_key));
+        }
+        if (t_part.__isset.end_keys) {
+            RETURN_IF_ERROR(_create_partition_keys(t_part.end_keys, 
&part->end_key));
+        }
+
+        part->num_buckets = t_part.num_buckets;
+        auto num_indexes = _schema->indexes().size();
+        if (t_part.indexes.size() != num_indexes) {
+            return Status::InternalError(
+                    "number of partition's index is not equal with schema's"
+                    ", num_part_indexes={}, num_schema_indexes={}",
+                    t_part.indexes.size(), num_indexes);
+        }
+        part->indexes = t_part.indexes;
+        std::sort(part->indexes.begin(), part->indexes.end(),
+                  [](const OlapTableIndexTablets& lhs, const 
OlapTableIndexTablets& rhs) {
+                      return lhs.index_id < rhs.index_id;
+                  });
+        // check index
+        for (int j = 0; j < num_indexes; ++j) {
+            if (part->indexes[j].index_id != _schema->indexes()[j]->index_id) {
+                std::stringstream ss;
+                ss << "partition's index is not equal with schema's"
+                   << ", part_index=" << part->indexes[j].index_id
+                   << ", schema_index=" << _schema->indexes()[j]->index_id;
+                return Status::InternalError(
+                        "partition's index is not equal with schema's"
+                        ", part_index={}, schema_index={}",
+                        part->indexes[j].index_id, 
_schema->indexes()[j]->index_id);
+            }
+        }
+        _partitions.emplace_back(part);
+        for (auto& in_key : part->in_keys) {

Review Comment:
   recheck the logic only in partition have `in_keys`, here must dispose the in 
partition and range partiton



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