github-actions[bot] commented on code in PR #26749: URL: https://github.com/apache/doris/pull/26749#discussion_r1404224884
########## be/src/olap/rowset/segment_v2/segment.cpp: ########## @@ -318,14 +330,42 @@ Status Segment::_load_index_impl() { }); } +// Return the storage datatype of related column to field. +// Return nullptr meaning no such storage infomation for this column +vectorized::DataTypePtr Segment::get_data_type_of(const Field& field, bool ignore_children) const { Review Comment: warning: method 'get_data_type_of' can be made static [readability-convert-member-functions-to-static] ```suggestion vectorized::DataTypePtr Segment::get_data_type_of(const Field& field, bool ignore_children) { ``` be/src/olap/rowset/segment_v2/segment.h:148: ```diff - std::shared_ptr<const vectorized::IDataType> get_data_type_of(const Field& filed, - bool ignore_children) const; + static std::shared_ptr<const vectorized::IDataType> get_data_type_of(const Field& filed, + bool ignore_children) ; ``` ########## be/src/olap/reader.cpp: ########## @@ -260,6 +261,16 @@ Status TabletReader::_capture_rs_readers(const ReaderParams& read_params) { return Status::OK(); } +TabletColumn TabletReader::materialize_column(const TabletColumn& orig) { Review Comment: warning: method 'materialize_column' can be made static [readability-convert-member-functions-to-static] be/src/olap/reader.h:267: ```diff - TabletColumn materialize_column(const TabletColumn& orig); + static TabletColumn materialize_column(const TabletColumn& orig); ``` ########## be/src/olap/rowset/segment_v2/segment_iterator.cpp: ########## @@ -1959,6 +2026,49 @@ Status SegmentIterator::next_batch(vectorized::Block* block) { return status; } +Status SegmentIterator::_convert_to_expected_type(const std::vector<ColumnId>& col_ids) { + for (ColumnId i : col_ids) { + if (_current_return_columns[i] == nullptr || _converted_column_ids[i] || + _is_pred_column[i]) { + continue; + } + if (!_segment->same_with_storage_type( + i, *_schema, _opts.io_ctx.reader_type != ReaderType::READER_QUERY)) { + const Field* field_type = _schema->column(i); + vectorized::DataTypePtr expected_type = Schema::get_data_type_ptr(*field_type); + vectorized::DataTypePtr file_column_type = _storage_name_and_type[i].second; + vectorized::ColumnPtr expected; + vectorized::ColumnPtr original = + _current_return_columns[i]->assume_mutable()->get_ptr(); + RETURN_IF_ERROR(vectorized::schema_util::cast_column({original, file_column_type, ""}, + expected_type, &expected)); + _current_return_columns[i] = expected->assume_mutable(); + _converted_column_ids[i] = 1; + VLOG_DEBUG << fmt::format("Convert {} fom file column type {} to {}, num_rows {}", + field_type->path().get_path(), file_column_type->get_name(), + expected_type->get_name(), + _current_return_columns[i]->size()); + } + } + return Status::OK(); +} + +Status SegmentIterator::copy_column_data_by_selector(vectorized::IColumn* input_col_ptr, + vectorized::MutableColumnPtr& output_col, + uint16_t* sel_rowid_idx, uint16_t select_size, + size_t batch_size) { + output_col->reserve(batch_size); + + // adapt for outer join change column to nullable + if (output_col->is_nullable() && !input_col_ptr->is_nullable()) { + auto col_ptr_nullable = reinterpret_cast<vectorized::ColumnNullable*>(output_col.get()); + col_ptr_nullable->get_null_map_column().insert_many_defaults(select_size); + output_col = col_ptr_nullable->get_nested_column_ptr(); + } + + return input_col_ptr->filter_by_selector(sel_rowid_idx, select_size, output_col); +} + Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { Review Comment: warning: function '_next_batch_internal' has cognitive complexity of 207 (threshold 50) [readability-function-cognitive-complexity] ```cpp Status SegmentIterator::_next_batch_internal(vectorized::Block* block) { ^ ``` <details> <summary>Additional context</summary> **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2076:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (UNLIKELY(!_lazy_inited)) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2077:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_lazy_init()); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2077:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_lazy_init()); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2079:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (_lazy_materialization_read || _opts.record_rowids || _is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2119:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (_wait_times_estimate_row_size > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2126:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp RETURN_IF_ERROR(_read_columns_by_index( ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2126:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_read_columns_by_index( ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2129:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (std::find(_first_read_column_ids.begin(), _first_read_column_ids.end(), ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2137:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (_current_batch_rows_read == 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2139:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_schema->column_ids())); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2139:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_schema->column_ids())); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2140:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp for (int i = 0; i < block->columns(); i++) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2143:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (!_is_pred_column[cid]) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2151:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!_is_need_vec_eval && !_is_need_short_eval && !_is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2151:** +1 ```cpp if (!_is_need_vec_eval && !_is_need_short_eval && !_is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2152:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_first_read_column_ids)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2152:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_first_read_column_ids)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2153:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_non_predicate_columns)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2153:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_non_predicate_columns)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2156:** +1, nesting level increased to 1 ```cpp } else { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2160:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (_is_need_vec_eval || _is_need_short_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2160:** +1 ```cpp if (_is_need_vec_eval || _is_need_short_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2172:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (selected_size > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2177:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(_output_column_by_sel_idx(block, _first_read_column_ids, ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2177:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp RETURN_IF_ERROR(_output_column_by_sel_idx(block, _first_read_column_ids, ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2181:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp if (_is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2183:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp if (!_second_read_column_ids.empty()) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2185:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp RETURN_IF_ERROR(_read_columns_by_rowids( ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2185:** +7, including nesting penalty of 6, nesting level increased to 7 ```cpp RETURN_IF_ERROR(_read_columns_by_rowids( ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2188:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp if (std::find(_second_read_column_ids.begin(), ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2193:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_second_read_column_ids)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2193:** +7, including nesting penalty of 6, nesting level increased to 7 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_second_read_column_ids)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2204:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp if (block->rows() == 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2214:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2214:** +7, including nesting penalty of 6, nesting level increased to 7 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2216:** +1, nesting level increased to 5 ```cpp } else { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2219:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2219:** +7, including nesting penalty of 6, nesting level increased to 7 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2222:** +1, nesting level increased to 3 ```cpp } else if (_is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2223:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_second_read_column_ids)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2223:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_second_read_column_ids)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2229:** +1, nesting level increased to 2 ```cpp } else if (_is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2231:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_first_read_column_ids)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2231:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_first_read_column_ids)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2237:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp for (uint32_t i = 0; i < selected_size; ++i) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2241:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (block->rows() == 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2251:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2251:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2253:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2256:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2256:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp RETURN_IF_ERROR(_execute_common_expr(sel_rowid_idx, selected_size, block)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2260:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (UNLIKELY(_opts.record_rowids)) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2263:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp for (auto i = 0; i < _selected_size; i++) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2268:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (_non_predicate_columns.empty()) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2272:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (UNLIKELY(_estimate_row_size) && block->rows() > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2272:** +1 ```cpp if (UNLIKELY(_estimate_row_size) && block->rows() > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2278:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (selected_size > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2279:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_read_columns_by_rowids(_non_predicate_columns, _block_rowids, ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2279:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(_read_columns_by_rowids(_non_predicate_columns, _block_rowids, ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2282:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (std::find(_non_predicate_columns.begin(), _non_predicate_columns.end(), ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2288:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_non_predicate_columns)); ^ ``` **be/src/common/status.h:523:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2288:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(_convert_to_expected_type(_non_predicate_columns)); ^ ``` **be/src/common/status.h:525:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2292:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!_is_need_expr_eval) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2310:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (UNLIKELY(_estimate_row_size) && block->rows() > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2310:** +1 ```cpp if (UNLIKELY(_estimate_row_size) && block->rows() > 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2315:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (_opts.read_orderby_key_reverse) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2317:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (num_rows == 0) { ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2322:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp for (size_t i = 0; i < num_rows; ++i) permutation.emplace_back(num_rows - 1 - i); ^ ``` **be/src/olap/rowset/segment_v2/segment_iterator.cpp:2324:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp for (size_t i = 0; i < num_columns; ++i) ^ ``` </details> ########## be/src/olap/rowset/segment_v2/segment.cpp: ########## @@ -515,5 +680,23 @@ return Status::OK(); } +bool Segment::same_with_storage_type(int32_t cid, const Schema& schema, Review Comment: warning: method 'same_with_storage_type' can be made static [readability-convert-member-functions-to-static] be/src/olap/rowset/segment_v2/segment.cpp:683: ```diff - bool ignore_children) const { + bool ignore_children) { ``` be/src/olap/rowset/segment_v2/segment.h:152: ```diff - bool same_with_storage_type(int32_t cid, const Schema& schema, bool ignore_children) const; + static bool same_with_storage_type(int32_t cid, const Schema& schema, bool ignore_children) ; ``` ########## be/src/olap/rowset/segment_v2/segment.cpp: ########## @@ -352,36 +501,53 @@ // but in the old schema column b's cid == 2 // but they are not the same column Status Segment::new_column_iterator(const TabletColumn& tablet_column, - std::unique_ptr<ColumnIterator>* iter) { + std::unique_ptr<ColumnIterator>* iter, + StorageReadOptions* opt) { + // init column iterator by path info + if (!tablet_column.path_info().empty() || tablet_column.is_variant_type()) { + return new_column_iterator_with_path(tablet_column, iter, opt); + } + // init default iterator if (_column_readers.count(tablet_column.unique_id()) < 1) { - if (!tablet_column.has_default_value() && !tablet_column.is_nullable()) { - return Status::InternalError("invalid nonexistent column without default value."); - } - auto type_info = get_type_info(&tablet_column); - std::unique_ptr<DefaultValueColumnIterator> default_value_iter( - new DefaultValueColumnIterator(tablet_column.has_default_value(), - tablet_column.default_value(), - tablet_column.is_nullable(), std::move(type_info), - tablet_column.precision(), tablet_column.frac())); - ColumnIteratorOptions iter_opts; - - RETURN_IF_ERROR(default_value_iter->init(iter_opts)); - *iter = std::move(default_value_iter); + RETURN_IF_ERROR(new_default_iterator(tablet_column, iter)); return Status::OK(); } + // init iterator by unique id ColumnIterator* it; RETURN_IF_ERROR(_column_readers.at(tablet_column.unique_id())->new_iterator(&it)); iter->reset(it); return Status::OK(); } +Status Segment::new_column_iterator(int32_t unique_id, std::unique_ptr<ColumnIterator>* iter) { + ColumnIterator* it; + RETURN_IF_ERROR(_column_readers.at(unique_id)->new_iterator(&it)); + iter->reset(it); + return Status::OK(); +} + +ColumnReader* Segment::_get_column_reader(const TabletColumn& col) { Review Comment: warning: method '_get_column_reader' can be made static [readability-convert-member-functions-to-static] be/src/olap/rowset/segment_v2/segment.h:186: ```diff - ColumnReader* _get_column_reader(const TabletColumn& col); + static ColumnReader* _get_column_reader(const TabletColumn& col); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org