@@ -1287,6 +1287,7 @@ void SegmentIterator::_vec_init_lazy_materialization() {
1287
1287
std::set<ColumnId> non_pred_set (_non_predicate_columns.begin (),
1288
1288
_non_predicate_columns.end ());
1289
1289
1290
+ DCHECK (_second_read_column_ids.empty ());
1290
1291
// _second_read_column_ids must be empty. Otherwise _lazy_materialization_read must not false.
1291
1292
for (int i = 0 ; i < _schema.num_column_ids (); i++) {
1292
1293
auto cid = _schema.column_id (i);
@@ -1704,15 +1705,19 @@ Status SegmentIterator::next_batch(vectorized::Block* block) {
1704
1705
}
1705
1706
1706
1707
// block->rows() takes the size of the first column by default. If the first column is no predicate column,
1707
- // it has not been read yet. Specify the column that has been read to calculate rows().
1708
- block->set_effective_col (_schema_block_id_map[*_common_expr_columns.begin ()]);
1708
+ // it has not been read yet. add a const column that has been read to calculate rows().
1709
+ if (block->rows () == 0 ) {
1710
+ auto res_column = vectorized::ColumnString::create ();
1711
+ res_column->insert_data (" " , 0 );
1712
+ auto col_const = vectorized::ColumnConst::create (std::move (res_column),
1713
+ selected_size);
1714
+ block->replace_by_position (0 , std::move (col_const));
1715
+ }
1709
1716
DCHECK (block->columns () > _schema_block_id_map[*_common_expr_columns.begin ()]);
1710
1717
_output_index_result_column (sel_rowid_idx, selected_size, block);
1711
1718
1712
1719
block->shrink_char_type_column_suffix_zero (_char_type_idx);
1713
1720
RETURN_IF_ERROR (_execute_common_expr (sel_rowid_idx, selected_size, block));
1714
-
1715
- block->set_effective_col (INT_MIN);
1716
1721
}
1717
1722
} else if (_is_need_expr_eval) {
1718
1723
for (auto cid : _second_read_column_ids) {
@@ -1731,12 +1736,16 @@ Status SegmentIterator::next_batch(vectorized::Block* block) {
1731
1736
sel_rowid_idx[i] = i;
1732
1737
}
1733
1738
1734
- block->set_effective_col (_schema_block_id_map[*_common_expr_columns.begin ()]);
1739
+ if (block->rows () == 0 ) {
1740
+ auto res_column = vectorized::ColumnString::create ();
1741
+ res_column->insert_data (" " , 0 );
1742
+ auto col_const =
1743
+ vectorized::ColumnConst::create (std::move (res_column), selected_size);
1744
+ block->replace_by_position (0 , std::move (col_const));
1745
+ }
1735
1746
_output_index_result_column (nullptr , 0 , block);
1736
1747
block->shrink_char_type_column_suffix_zero (_char_type_idx);
1737
1748
RETURN_IF_ERROR (_execute_common_expr (sel_rowid_idx, selected_size, block));
1738
-
1739
- block->set_effective_col (INT_MIN);
1740
1749
}
1741
1750
1742
1751
if (UNLIKELY (_opts.record_rowids )) {
0 commit comments