Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Jan 3, 2025
1 parent 22a7a46 commit fba14f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
34 changes: 12 additions & 22 deletions be/src/olap/partial_update_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,18 @@ Status PartialUpdateInfo::init(int64_t tablet_id, int64_t txn_id, const TabletSc
missing_cids.clear();
update_cids.clear();

// partial_update_cols should include all key columns
for (std::size_t i {0}; i < tablet_schema.num_key_columns(); i++) {
const auto key_col = tablet_schema.column(i);
if (!partial_update_cols.contains(key_col.name())) {
auto msg = fmt::format(
"Unable to do partial update on shadow index's tablet, tablet_id={}, "
"txn_id={}. Missing key column {}.",
tablet_id, txn_id, key_col.name());
LOG_WARNING(msg);
return Status::Aborted<false>(msg);
}
}

// every including columns should be in tablet_schema
for (const auto& col : partial_update_cols) {
if (-1 == tablet_schema.field_index(col)) {
auto msg = fmt::format(
"Unable to do partial update on shadow index's tablet, tablet_id={}, "
"txn_id={}. Can't find column {} in tablet's schema.",
tablet_id, txn_id, col);
LOG_WARNING(msg);
return Status::Aborted<false>(msg);
if (partial_update_mode == UniqueKeyUpdateModePB::UPDATE_FIXED_COLUMNS) {
// partial_update_cols should include all key columns
for (std::size_t i {0}; i < tablet_schema.num_key_columns(); i++) {
const auto key_col = tablet_schema.column(i);
if (!partial_update_cols.contains(key_col.name())) {
auto msg = fmt::format(
"Unable to do partial update on shadow index's tablet, tablet_id={}, "
"txn_id={}. Missing key column {}.",
tablet_id, txn_id, key_col.name());
LOG_WARNING(msg);
return Status::Aborted<false>(msg);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@

-- !sql --
1 \N 1 1 2 0
1 \N \N \N 6 1
2 \N 2 2 2 0
2 \N \N \N 6 1
3 \N 3 3 2 0
3 \N \N \N 6 1
4 \N 4 4 5 0
5 \N 5 5 5 0
6 \N 6 6 5 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ suite("test_add_key_partial_update", "nonConcurrent") {
sql "alter table ${table1} ADD COLUMN k2 int key;"

Thread.sleep(1000)
sql "delete from ${table1} where k1<=3;"
test {
sql "delete from ${table1} where k1<=3;"
exception "Unable to do partial update on shadow index's tablet"
}

waitForSchemaChangeDone {
sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${table1}' ORDER BY createtime DESC LIMIT 1 """
Expand Down

0 comments on commit fba14f2

Please sign in to comment.