From be03238ab1477e7c3078f62e6d516185560d1289 Mon Sep 17 00:00:00 2001 From: amorynan Date: Thu, 20 Jun 2024 22:33:24 +0800 Subject: [PATCH 1/2] improve upgrade action for map column from 1.2.* to 2.0.* --- be/src/olap/rowset/segment_v2/column_reader.cpp | 1 + be/src/olap/rowset/segment_v2/column_writer.cpp | 5 +++++ be/src/olap/tablet_schema.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp b/be/src/olap/rowset/segment_v2/column_reader.cpp index 45ae123ae36d11..917f6563d80a50 100644 --- a/be/src/olap/rowset/segment_v2/column_reader.cpp +++ b/be/src/olap/rowset/segment_v2/column_reader.cpp @@ -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 key_reader; RETURN_IF_ERROR(ColumnReader::create(opts, meta.children_columns(0), meta.children_columns(0).num_rows(), file_reader, diff --git a/be/src/olap/rowset/segment_v2/column_writer.cpp b/be/src/olap/rowset/segment_v2/column_writer.cpp index 19a0c4f3a849d5..4de593278b1d94 100644 --- a/be/src/olap/rowset/segment_v2/column_writer.cpp +++ b/be/src/olap/rowset/segment_v2/column_writer.cpp @@ -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> inner_writer_list; for (int i = 0; i < 2; ++i) { diff --git a/be/src/olap/tablet_schema.cpp b/be/src/olap/tablet_schema.cpp index 6dd04782588e24..82c52195cff8a8 100644 --- a/be/src/olap/tablet_schema.cpp +++ b/be/src/olap/tablet_schema.cpp @@ -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; @@ -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++) { From 218339d097d18d369bd0bc97bcf4e2fc6c9919c0 Mon Sep 17 00:00:00 2001 From: amorynan Date: Fri, 21 Jun 2024 13:49:50 +0800 Subject: [PATCH 2/2] fix error message --- be/src/olap/rowset/segment_v2/column_writer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/column_writer.cpp b/be/src/olap/rowset/segment_v2/column_writer.cpp index 4de593278b1d94..6f618cc1ddc38b 100644 --- a/be/src/olap/rowset/segment_v2/column_writer.cpp +++ b/be/src/olap/rowset/segment_v2/column_writer.cpp @@ -263,9 +263,9 @@ 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."); + 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> inner_writer_list;