Skip to content

Commit

Permalink
[BugFix] Fix get struct ordinal index error (backport #44608) (#44667)
Browse files Browse the repository at this point in the history
Signed-off-by: Seaven <[email protected]>
  • Loading branch information
Seaven committed Apr 24, 2024
1 parent 50638ea commit 34f131b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions be/src/storage/rowset/struct_column_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "column/nullable_column.h"
#include "column/struct_column.h"
#include "storage/rowset/column_reader.h"
#include "storage/rowset/common.h"
#include "storage/rowset/scalar_column_iterator.h"

namespace starrocks {
Expand All @@ -39,7 +40,7 @@ class StructColumnIterator final : public ColumnIterator {

Status seek_to_ordinal(ordinal_t ord) override;

ordinal_t get_current_ordinal() const override { return _field_iters[0]->get_current_ordinal(); }
ordinal_t get_current_ordinal() const override { return _current_ordinal; }

/// for vectorized engine
Status get_row_ranges_by_zone_map(const std::vector<const ColumnPredicate*>& predicates,
Expand All @@ -55,6 +56,7 @@ class StructColumnIterator final : public ColumnIterator {
const ColumnAccessPath* _path;

std::vector<uint8_t> _access_flags;
ordinal_t _current_ordinal = 0;
};

StatusOr<std::unique_ptr<ColumnIterator>> create_struct_iter(ColumnReader* _reader,
Expand Down Expand Up @@ -117,6 +119,7 @@ Status StructColumnIterator::next_batch(size_t* n, Column* dst) {
if (_access_flags[i]) {
auto num_to_read = *n;
RETURN_IF_ERROR(_field_iters[i]->next_batch(&num_to_read, fields[i].get()));
_current_ordinal = _field_iters[i]->get_current_ordinal();
}
}

Expand Down Expand Up @@ -153,6 +156,7 @@ Status StructColumnIterator::next_batch(const SparseRange& range, Column* dst) {
if (_access_flags[i]) {
RETURN_IF_ERROR(_field_iters[i]->next_batch(range, fields[i].get()));
row_count = fields[i]->size();
_current_ordinal = _field_iters[i]->get_current_ordinal();
}
}

Expand Down Expand Up @@ -183,6 +187,7 @@ Status StructColumnIterator::fetch_values_by_rowid(const rowid_t* rowids, size_t
for (int i = 0; i < _field_iters.size(); ++i) {
if (_access_flags[i]) {
RETURN_IF_ERROR(_field_iters[i]->fetch_values_by_rowid(rowids, size, fields[i].get()));
_current_ordinal = _field_iters[i]->get_current_ordinal();
}
}

Expand All @@ -201,6 +206,7 @@ Status StructColumnIterator::seek_to_first() {
for (auto& iter : _field_iters) {
RETURN_IF_ERROR(iter->seek_to_first());
}
_current_ordinal = _field_iters[0]->get_current_ordinal();
return Status::OK();
}

Expand All @@ -211,6 +217,7 @@ Status StructColumnIterator::seek_to_ordinal(ordinal_t ord) {
for (auto& iter : _field_iters) {
RETURN_IF_ERROR(iter->seek_to_ordinal(ord));
}
_current_ordinal = _field_iters[0]->get_current_ordinal();
return Status::OK();
}

Expand All @@ -219,5 +226,4 @@ Status StructColumnIterator::get_row_ranges_by_zone_map(const std::vector<const
row_ranges->add({0, static_cast<rowid_t>(_reader->num_rows())});
return Status::OK();
}

} // namespace starrocks

0 comments on commit 34f131b

Please sign in to comment.