Skip to content

Commit

Permalink
improve upgrade action for map column from 1.2.* to 2.0.*
Browse files Browse the repository at this point in the history
  • Loading branch information
amorynan committed Jun 20, 2024
1 parent c8ef1f5 commit be03238
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Status ColumnReader::create(const ColumnReaderOptions& opts, const ColumnMetaPB&
}
case FieldType::OLAP_FIELD_TYPE_MAP: {
// map reader now has 3 sub readers for key, value, offsets(scalar), null(scala)
DCHECK(meta.children_columns_size() == 3 || meta.children_columns_size() == 4);
std::unique_ptr<ColumnReader> key_reader;
RETURN_IF_ERROR(ColumnReader::create(opts, meta.children_columns(0),
meta.children_columns(0).num_rows(), file_reader,
Expand Down
5 changes: 5 additions & 0 deletions be/src/olap/rowset/segment_v2/column_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ Status ColumnWriter::create(const ColumnWriterOptions& opts, const TabletColumn*
}
case FieldType::OLAP_FIELD_TYPE_MAP: {
DCHECK(column->get_subtype_count() == 2);
if (column->get_subtype_count() < 2) {
return Status::InvalidArgument(
"If you upgraded from version 1.2.*, please drop the "
"map column and wait a while to re-create the map column.");
}
// create key & value writer
std::vector<std::unique_ptr<ColumnWriter>> inner_writer_list;
for (int i = 0; i < 2; ++i) {
Expand Down
6 changes: 4 additions & 2 deletions be/src/olap/tablet_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ void TabletColumn::init_from_pb(const ColumnPB& column) {
CHECK(column.children_columns_size() == 1) << "ARRAY type has more than 1 children types.";
}
if (_type == FieldType::OLAP_FIELD_TYPE_MAP) {
CHECK(column.children_columns_size() == 2) << "MAP type has more than 2 children types.";
DCHECK(column.children_columns_size() == 2) << "MAP type has more than 2 children types.";
LOG(WARNING) << "MAP type has more than 2 children types.";
}
for (size_t i = 0; i < column.children_columns_size(); i++) {
TabletColumn child_column;
Expand Down Expand Up @@ -481,7 +482,8 @@ void TabletColumn::to_schema_pb(ColumnPB* column) const {
CHECK(_sub_columns.size() == 1) << "ARRAY type has more than 1 children types.";
}
if (_type == FieldType::OLAP_FIELD_TYPE_MAP) {
CHECK(_sub_columns.size() == 2) << "MAP type has more than 2 children types.";
DCHECK(_sub_columns.size() == 2) << "MAP type has more than 2 children types.";
LOG(WARNING) << "MAP type has more than 2 children types.";
}

for (size_t i = 0; i < _sub_columns.size(); i++) {
Expand Down

0 comments on commit be03238

Please sign in to comment.