From e778367113ff2b038434d59163ac3c9e83cb88c0 Mon Sep 17 00:00:00 2001 From: cambyzju Date: Tue, 19 Apr 2022 22:01:18 +0800 Subject: [PATCH] Bug fix for ArrayColumn Iterator --- be/src/olap/rowset/segment_v2/column_reader.cpp | 3 ++- be/src/olap/rowset/segment_v2/column_reader.h | 2 +- be/src/olap/rowset/segment_v2/segment_iterator.cpp | 7 +++++++ 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 9f6e642292f24a..d39302f000f485 100644 --- a/be/src/olap/rowset/segment_v2/column_reader.cpp +++ b/be/src/olap/rowset/segment_v2/column_reader.cpp @@ -417,7 +417,8 @@ Status ArrayFileColumnIterator::next_batch(size_t* n, ColumnBlockView* dst, bool array_batch->get_offset_by_length(dst->current_offset(), *n); // 2. read null - if (dst->is_nullable()) { + if (_array_reader->is_nullable()) { + DCHECK(dst->is_nullable()); auto null_batch = array_batch->get_null_as_batch(); ColumnBlock null_block(&null_batch, nullptr); ColumnBlockView null_view(&null_block, dst->current_offset()); diff --git a/be/src/olap/rowset/segment_v2/column_reader.h b/be/src/olap/rowset/segment_v2/column_reader.h index 75dd2d17888cf2..305ba5f8dc50d4 100644 --- a/be/src/olap/rowset/segment_v2/column_reader.h +++ b/be/src/olap/rowset/segment_v2/column_reader.h @@ -351,7 +351,7 @@ class ArrayFileColumnIterator final : public ColumnIterator { ordinal_t start_offset_in_this_page = _length_iterator->get_current_page()->first_array_item_ordinal; ColumnBlock ordinal_block(_length_batch.get(), nullptr); - ordinal_t size_to_read = ord - start_offset_in_this_page; + ordinal_t size_to_read = ord - _length_iterator->get_current_ordinal(); bool has_null = false; ordinal_t item_ordinal = start_offset_in_this_page; while (size_to_read > 0) { diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index 6c342c6742acab..fce68258ba70d9 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -463,6 +463,13 @@ void SegmentIterator::_init_lazy_materialization() { } _opts.delete_condition_predicates->get_all_column_ids(predicate_columns); + // ARRAY column do not support lazy materialization read + for (auto cid : _schema.column_ids()) { + if (_schema.column(cid)->type() == OLAP_FIELD_TYPE_ARRAY) { + predicate_columns.insert(cid); + } + } + // when all return columns have predicates, disable lazy materialization to avoid its overhead if (_schema.column_ids().size() > predicate_columns.size()) { _lazy_materialization_read = true;