Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](map) fix core dump when upgrading from 1.2.x to 2.0.x with map datatype column #36635

Merged
merged 2 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
amorynan marked this conversation as resolved.
Show resolved Hide resolved
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::InternalError(
"If you upgraded from version 1.2.*, please DROP the MAP columns and then "
"ADD the MAP columns back.");
}
// 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
Loading