Skip to content

Commit

Permalink
fix schema change
Browse files Browse the repository at this point in the history
  • Loading branch information
mymeiyi committed Dec 11, 2024
1 parent 72c9f64 commit 0da45c7
Show file tree
Hide file tree
Showing 4 changed files with 20,600 additions and 64 deletions.
20 changes: 11 additions & 9 deletions be/src/olap/schema_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& reques
for (int i = 0; i < num_cols; ++i) {
return_columns[i] = i;
}
std::vector<uint32_t> cluster_key_idxes;

// begin to find deltas to convert from base tablet to new tablet so that
// obtain base tablet and new tablet's push lock and header write lock to prevent loading data
Expand Down Expand Up @@ -980,6 +981,14 @@ Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& reques
reader_context.batch_size = ALTER_TABLE_BATCH_SIZE;
reader_context.delete_bitmap = &_base_tablet->tablet_meta()->delete_bitmap();
reader_context.version = Version(0, end_version);
if (!_base_tablet_schema->cluster_key_uids().empty()) {
for (const auto& uid : _base_tablet_schema->cluster_key_uids()) {
cluster_key_idxes.emplace_back(_base_tablet_schema->field_index(uid));
}
reader_context.read_orderby_key_columns = &cluster_key_idxes;
reader_context.is_unique = false;
reader_context.sequence_id_idx = -1;
}
for (auto& rs_split : rs_splits) {
res = rs_split.rs_reader->init(&reader_context);
if (!res) {
Expand Down Expand Up @@ -1366,15 +1375,8 @@ Status SchemaChangeJob::parse_request(const SchemaChangeParams& sc_params,

if (sc_params.enable_unique_key_merge_on_write &&
new_tablet_schema->num_key_columns() > base_tablet_schema->num_key_columns()) {
if (base_tablet_schema->cluster_key_uids().empty()) {
*sc_directly = true;
return Status::OK();
} else {
// For mow table with cluster keys, the data in segments of one rowset is sorted by
// cluster keys, the short key index may be overlapped.
*sc_sorting = true;
return Status::OK();
}
*sc_directly = true;
return Status::OK();
}

if (base_tablet_schema->num_short_key_columns() != new_tablet_schema->num_short_key_columns()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
-- !select1 --
12345 23083 \N 30920 40410

-- !select2 --
17320 24209 \N 30795 40000

-- !select3 --
59832 36673 \N 30343 40299

-- !select1 --
12345 23083 \N 30920 40410

-- !select2 --
17320 24209 \N 30795 40000

-- !select3 --
59832 36673 \N 30586 40739

Loading

0 comments on commit 0da45c7

Please sign in to comment.