Skip to content

Commit

Permalink
[Fix](Variant) variant fallthrough with inverted index (apache#40069)
Browse files Browse the repository at this point in the history
When reading from segment, the schema type is variant, if we check type
valid in `get_inverted_index`, the result should always return
nullptr(since variant type it self does not support inverted index), but
the actual storage could be `string` or etc.So we should ignore the type
check and return the correct inverted index iterators

introduced by apache#36163
  • Loading branch information
eldenmoon committed Sep 3, 2024
1 parent e3b1d0c commit 3314c8b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 4 additions & 2 deletions be/src/olap/rowset/segment_v2/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ Status Segment::new_iterator(SchemaSPtr schema, const StorageReadOptions& read_o
ColumnReader* reader = nullptr;
if (col.is_extracted_column()) {
auto relative_path = col.path_info_ptr()->copy_pop_front();
const auto* node = _sub_column_tree[col.unique_id()].find_exact(relative_path);
int32_t unique_id = col.unique_id() > 0 ? col.unique_id() : col.parent_unique_id();
const auto* node = _sub_column_tree[unique_id].find_exact(relative_path);
reader = node != nullptr ? node->data.reader.get() : nullptr;
} else {
reader = _column_readers.contains(col.unique_id())
Expand Down Expand Up @@ -775,8 +776,9 @@ ColumnReader* Segment::_get_column_reader(const TabletColumn& col) {
// init column iterator by path info
if (col.has_path_info() || col.is_variant_type()) {
auto relative_path = col.path_info_ptr()->copy_pop_front();
int32_t unique_id = col.unique_id() > 0 ? col.unique_id() : col.parent_unique_id();
const auto* node = col.has_path_info()
? _sub_column_tree[col.unique_id()].find_exact(relative_path)
? _sub_column_tree[unique_id].find_exact(relative_path)
: nullptr;
if (node != nullptr) {
return node->data.reader.get();
Expand Down
7 changes: 6 additions & 1 deletion be/src/olap/rowset/segment_v2/segment_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,10 +1488,15 @@ Status SegmentIterator::_init_inverted_index_iterators() {
}
for (auto cid : _schema->column_ids()) {
if (_inverted_index_iterators[cid] == nullptr) {
// Not check type valid, since we need to get inverted index for related variant type when reading the segment.
// If check type valid, we can not get inverted index for variant type, and result nullptr.The result for calling
// get_inverted_index with variant suffix should return corresponding inverted index meta.
bool check_inverted_index_by_type = false;
// Use segment’s own index_meta, for compatibility with future indexing needs to default to lowercase.
RETURN_IF_ERROR(_segment->new_inverted_index_iterator(
_opts.tablet_schema->column(cid),
_segment->_tablet_schema->get_inverted_index(_opts.tablet_schema->column(cid)),
_segment->_tablet_schema->get_inverted_index(_opts.tablet_schema->column(cid),
check_inverted_index_by_type),
_opts, &_inverted_index_iterators[cid]));
}
}
Expand Down
Loading

0 comments on commit 3314c8b

Please sign in to comment.