diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index 199502d54494a32..ecfdfdfac25f8ed 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -2327,6 +2327,7 @@ Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { RETURN_IF_ERROR(_convert_to_expected_type(_first_read_column_ids)); RETURN_IF_ERROR(_convert_to_expected_type(_non_predicate_columns)); _output_non_pred_columns(block); + block->shrink_char_type_column_suffix_zero(_char_type_idx_no_0); if (!_enable_common_expr_pushdown || !_remaining_conjunct_roots.empty()) { _output_index_result_column(nullptr, 0, block); } @@ -2386,14 +2387,14 @@ Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { auto col_const = vectorized::ColumnConst::create(std::move(res_column), selected_size); block->replace_by_position(0, std::move(col_const)); - _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); block->shrink_char_type_column_suffix_zero(_char_type_idx_no_0); + _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); RETURN_IF_ERROR( _execute_common_expr(_sel_rowid_idx.data(), selected_size, block)); block->replace_by_position(0, std::move(col0)); } else { - _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); block->shrink_char_type_column_suffix_zero(_char_type_idx); + _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); RETURN_IF_ERROR( _execute_common_expr(_sel_rowid_idx.data(), selected_size, block)); } @@ -2425,13 +2426,13 @@ Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { auto col_const = vectorized::ColumnConst::create(std::move(res_column), selected_size); block->replace_by_position(0, std::move(col_const)); - _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); block->shrink_char_type_column_suffix_zero(_char_type_idx_no_0); + _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); RETURN_IF_ERROR(_execute_common_expr(_sel_rowid_idx.data(), selected_size, block)); block->replace_by_position(0, std::move(col0)); } else { - _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); block->shrink_char_type_column_suffix_zero(_char_type_idx); + _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); RETURN_IF_ERROR(_execute_common_expr(_sel_rowid_idx.data(), selected_size, block)); } } @@ -2442,9 +2443,10 @@ Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { } if (_non_predicate_columns.empty()) { - // shrink char_type suffix zero data - block->shrink_char_type_column_suffix_zero(_char_type_idx); - + if (!_is_need_expr_eval) { + block->shrink_char_type_column_suffix_zero(_char_type_idx); + _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); + } return Status::OK(); } // step4: read non_predicate column @@ -2463,13 +2465,11 @@ Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { _output_non_pred_columns(block); if (!_is_need_expr_eval) { + block->shrink_char_type_column_suffix_zero(_char_type_idx); _output_index_result_column(_sel_rowid_idx.data(), selected_size, block); } } - // shrink char_type suffix zero data - block->shrink_char_type_column_suffix_zero(_char_type_idx); - #ifndef NDEBUG size_t rows = block->rows(); for (const auto& entry : *block) {