Skip to content

Commit 9d3eb42

Browse files
obdevfootka
authored andcommitted
[CP] [vector index] fix replace into with sixth table part key issue
Co-authored-by: footka <672528926@qq.com>
1 parent 25b82fd commit 9d3eb42

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

src/sql/das/iter/ob_das_domain_id_merge_iter.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,20 @@ int ObDASDomainIdMergeIter::get_domain_id(
940940
}
941941
if (OB_SUCC(ret)) {
942942
const int64_t rowkey_cnt = ctdef->table_param_.get_read_info().get_schema_rowkey_count();
943+
int64_t part_key_num = 0;
943944
ObExpr *expr = nullptr;
944945
int64_t expect_result_output_cnt = rowkey_cnt + 1;
945946
expect_result_output_cnt = OB_NOT_NULL(ctdef->trans_info_expr_) ? (expect_result_output_cnt + 1) : expect_result_output_cnt;
946947
expect_result_output_cnt = (domain_type == ObDomainIdUtils::IVFPQ_CID) ? (expect_result_output_cnt + 1) : expect_result_output_cnt;
948+
// when partition and heap organization table, use hybrid vector index; the dml return all_columns as output, but tsc only use
949+
// rowkey and embeded_vec; the dml has more columns that is partition key.
950+
if (domain_type != ObDomainIdUtils::EMB_VEC) {
951+
// skip, do nothing
952+
} else if (OB_FAIL(check_table_need_add_part_key(data_table_iter_->get_scan_param().index_id_, part_key_num, ctdef))) {
953+
LOG_WARN("fail to check embedded table add part key ", K(ret), K(data_table_iter_->get_scan_param().index_id_), K(ctdef->ref_table_id_));
954+
} else {
955+
expect_result_output_cnt = expect_result_output_cnt + part_key_num;
956+
}
947957
// When the defensive check level is set to 2 (strict defensive check), the transaction information of the current
948958
// row is recorded for 4377 diagnosis. Then, it will add pseudo_trans_info_expr into result output of das scan.
949959
//
@@ -955,7 +965,7 @@ int ObDASDomainIdMergeIter::get_domain_id(
955965

956966
int domain_id_num = (domain_type == ObDomainIdUtils::IVFPQ_CID) ? 2 : 1;
957967
for (int i = 0; OB_SUCC(ret) && i < domain_id_num; ++i) {
958-
if (OB_ISNULL(expr = ctdef->result_output_.at(rowkey_cnt + i))) {
968+
if (OB_ISNULL(expr = ctdef->result_output_.at(rowkey_cnt + part_key_num + i))) {
959969
ret = OB_ERR_UNEXPECTED;
960970
LOG_WARN("unexpected error, domain id expr is nullptr", K(ret), K(rowkey_cnt), K(ctdef->result_output_));
961971
} else {
@@ -1455,6 +1465,34 @@ int ObDASDomainIdMergeIter::check_use_rowkey_vid_tbl_by_table_id(int64_t table_i
14551465
return ret;
14561466
}
14571467

1468+
int ObDASDomainIdMergeIter::check_table_need_add_part_key(int64_t table_id, int64_t &part_key_num, const ObDASScanCtDef *ctdef)
1469+
{
1470+
int ret = OB_SUCCESS;
1471+
part_key_num = 0;
1472+
share::schema::ObSchemaGetterGuard schema_guard;
1473+
ObIArray<uint64_t> *column_ids;
1474+
const ObTableSchema *table_schema = nullptr;
1475+
const ObTableSchema *domain_table_schema = nullptr;
1476+
if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(MTL_ID(), schema_guard))) {
1477+
LOG_WARN("fail to get schema guard", K(ret));
1478+
} else if (OB_FAIL(schema_guard.get_table_schema(MTL_ID(), table_id, table_schema))) {
1479+
LOG_WARN("fail to get table schema", K(ret), K(table_id));
1480+
} else if (OB_ISNULL(table_schema)) {
1481+
ret = OB_ERR_UNEXPECTED;
1482+
LOG_WARN("table schema is null", K(ret), K(table_id));
1483+
} else if (OB_FAIL(schema_guard.get_table_schema(MTL_ID(), ctdef->ref_table_id_, domain_table_schema))) {
1484+
LOG_WARN("fail to get table schema", K(ret), K(ctdef->ref_table_id_));
1485+
} else if (OB_ISNULL(domain_table_schema)) {
1486+
ret = OB_ERR_UNEXPECTED;
1487+
LOG_WARN("table schema is null", K(ret), K(table_id));
1488+
} else if (table_schema->is_table_with_hidden_pk_column() && table_schema->is_partitioned_table()) {
1489+
if (ctdef->result_output_.count() == domain_table_schema->get_column_count()) {
1490+
part_key_num += table_schema->get_part_level();
1491+
}
1492+
}
1493+
return ret;
1494+
}
1495+
14581496
int ObDASDomainIdMergeIter::fill_null_domain_id_in_data_table(
14591497
const ObDASScanCtDef *ctdef,
14601498
ObDASScanRtDef *rtdef,

src/sql/das/iter/ob_das_domain_id_merge_iter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class ObDASDomainIdMergeIter final : public ObDASIter
163163
int check_is_emb_vec_domain(int64_t iter_idx, bool &is_emb_vec);
164164
int check_is_emb_vec_domain_by_table_id(int64_t table_id, bool &is_emb_vec);
165165
int check_use_rowkey_vid_tbl_by_table_id(int64_t table_id, bool &use_rowkey_vid_tbl);
166+
int check_table_need_add_part_key(int64_t table_id, int64_t &part_key_num, const ObDASScanCtDef *ctdef);
166167
int reset_rowkey_domain_iter_scan_range(int64_t iter_idx, const common::ObRowkey &data_table_rowkey);
167168
int fill_null_domain_id_in_data_table(const ObDASScanCtDef *ctdef,
168169
ObDASScanRtDef *rtdef,

0 commit comments

Comments
 (0)