Skip to content

Commit

Permalink
[fix](sequence) fix that update table core dump with sequence column (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoxin01 committed Nov 3, 2022
1 parent 88646dc commit c58ac39
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
39 changes: 19 additions & 20 deletions be/src/exec/olap_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Status OlapScanner::_init_tablet_reader_params(

_tablet_reader_params.direct_mode = single_version || _aggregation;

RETURN_IF_ERROR(_init_return_columns(!_tablet_reader_params.direct_mode));
RETURN_IF_ERROR(_init_return_columns());

_tablet_reader_params.tablet = _tablet;
_tablet_reader_params.reader_type = READER_QUERY;
Expand Down Expand Up @@ -204,6 +204,23 @@ Status OlapScanner::_init_tablet_reader_params(
_tablet_reader_params.return_columns.push_back(index);
}
}

// expand the sequence column
if (_tablet->tablet_schema().has_sequence_col()) {
bool has_replace_col = false;
for (auto col : _return_columns) {
if (_tablet->tablet_schema().column(col).aggregation() ==
FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE) {
has_replace_col = true;
break;
}
}
if (auto sequence_col_idx = _tablet->tablet_schema().sequence_col_idx();
has_replace_col && std::find(_return_columns.begin(), _return_columns.end(),
sequence_col_idx) == _return_columns.end()) {
_tablet_reader_params.return_columns.push_back(sequence_col_idx);
}
}
}

// use _tablet_reader_params.return_columns, because reader use this to merge sort
Expand All @@ -227,7 +244,7 @@ Status OlapScanner::_init_tablet_reader_params(
return Status::OK();
}

Status OlapScanner::_init_return_columns(bool need_seq_col) {
Status OlapScanner::_init_return_columns() {
for (auto slot : _tuple_desc->slots()) {
if (!slot->is_materialized()) {
continue;
Expand All @@ -244,24 +261,6 @@ Status OlapScanner::_init_return_columns(bool need_seq_col) {
_tablet_columns_convert_to_null_set.emplace(index);
_query_slots.push_back(slot);
}

// expand the sequence column
if (_tablet->tablet_schema().has_sequence_col() && need_seq_col) {
bool has_replace_col = false;
for (auto col : _return_columns) {
if (_tablet->tablet_schema().column(col).aggregation() ==
FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE) {
has_replace_col = true;
break;
}
}
if (auto sequence_col_idx = _tablet->tablet_schema().sequence_col_idx();
has_replace_col && std::find(_return_columns.begin(), _return_columns.end(),
sequence_col_idx) == _return_columns.end()) {
_return_columns.push_back(sequence_col_idx);
}
}

if (_return_columns.empty()) {
return Status::InternalError("failed to build storage scanner, no materialized slot!");
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/olap_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class OlapScanner {
const std::vector<OlapScanRange*>& key_ranges, const std::vector<TCondition>& filters,
const std::vector<std::pair<string, std::shared_ptr<IBloomFilterFuncBase>>>&
bloom_filters);
Status _init_return_columns(bool need_seq_col);
Status _init_return_columns();
void _convert_row_to_tuple(Tuple* tuple);

// Update profile that need to be reported in realtime.
Expand Down
3 changes: 1 addition & 2 deletions be/src/vec/olap/block_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ void BlockReader::_init_agg_state(const ReaderParams& read_params) {
OLAPStatus BlockReader::init(const ReaderParams& read_params) {
TabletReader::init(read_params);

auto return_column_size =
read_params.origin_return_columns->size() - (_sequence_col_idx != -1 ? 1 : 0);
auto return_column_size = read_params.origin_return_columns->size();
_return_columns_loc.resize(read_params.return_columns.size());
for (int i = 0; i < return_column_size; ++i) {
auto cid = read_params.origin_return_columns->at(i);
Expand Down

0 comments on commit c58ac39

Please sign in to comment.