github-actions[bot] commented on code in PR #34925: URL: https://github.com/apache/doris/pull/34925#discussion_r1602588713
########## be/src/vec/common/schema_util.cpp: ########## @@ -483,25 +486,8 @@ Status get_least_common_schema(const std::vector<TabletSchemaSPtr>& schemas, return Status::OK(); } -Status parse_and_encode_variant_columns(Block& block, const std::vector<int>& variant_pos, - const ParseContext& ctx) { - try { - // Parse each variant column from raw string column - RETURN_IF_ERROR(vectorized::schema_util::parse_variant_columns(block, variant_pos, ctx)); - vectorized::schema_util::finalize_variant_columns(block, variant_pos, - false /*not ingore sparse*/); - RETURN_IF_ERROR( - vectorized::schema_util::encode_variant_sparse_subcolumns(block, variant_pos)); - } catch (const doris::Exception& e) { - // TODO more graceful, max_filter_ratio - LOG(WARNING) << "encounter execption " << e.to_string(); - return Status::InternalError(e.to_string()); - } - return Status::OK(); -} - -Status parse_variant_columns(Block& block, const std::vector<int>& variant_pos, - const ParseContext& ctx) { +Status _parse_variant_columns(Block& block, const std::vector<int>& variant_pos, Review Comment: warning: function '_parse_variant_columns' has cognitive complexity of 59 (threshold 50) [readability-function-cognitive-complexity] ```cpp Status _parse_variant_columns(Block& block, const std::vector<int>& variant_pos, ^ ``` <details> <summary>Additional context</summary> **be/src/vec/common/schema_util.cpp:490:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp for (int i = 0; i < variant_pos.size(); ++i) { ^ ``` **be/src/vec/common/schema_util.cpp:500:** nesting level increased to 2 ```cpp auto encode_rowstore = [&]() { ^ ``` **be/src/vec/common/schema_util.cpp:501:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (!ctx.record_raw_json_column) { ^ ``` **be/src/vec/common/schema_util.cpp:505:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (record_raw_string_with_serialization) { ^ ``` **be/src/vec/common/schema_util.cpp:508:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp for (size_t i = 0; i < var->rows(); ++i) { ^ ``` **be/src/vec/common/schema_util.cpp:510:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp RETURN_IF_ERROR(var->serialize_one_row_to_string(i, &raw_str)); ^ ``` **be/src/common/status.h:570:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/vec/common/schema_util.cpp:510:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp RETURN_IF_ERROR(var->serialize_one_row_to_string(i, &raw_str)); ^ ``` **be/src/common/status.h:572:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/vec/common/schema_util.cpp:514:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/vec/common/schema_util.cpp:524:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!var.is_scalar_variant()) { ^ ``` **be/src/vec/common/schema_util.cpp:527:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(encode_rowstore()); ^ ``` **be/src/common/status.h:570:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/vec/common/schema_util.cpp:527:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(encode_rowstore()); ^ ``` **be/src/common/status.h:572:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/vec/common/schema_util.cpp:532:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (WhichDataType(remove_nullable(var.get_root_type())).is_json()) { ^ ``` **be/src/vec/common/schema_util.cpp:535:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(cast_column({var.get_root(), var.get_root_type(), ""}, ^ ``` **be/src/common/status.h:570:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/vec/common/schema_util.cpp:537:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp ? make_nullable(std::make_shared<DataTypeString>()) ^ ``` **be/src/vec/common/schema_util.cpp:535:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp RETURN_IF_ERROR(cast_column({var.get_root(), var.get_root_type(), ""}, ^ ``` **be/src/common/status.h:572:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` **be/src/vec/common/schema_util.cpp:540:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (raw_json_column->is_nullable()) { ^ ``` **be/src/vec/common/schema_util.cpp:544:** +1, nesting level increased to 2 ```cpp } else { ^ ``` **be/src/vec/common/schema_util.cpp:548:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp ? assert_cast<const ColumnNullable&>(root).get_nested_column_ptr() ^ ``` **be/src/vec/common/schema_util.cpp:558:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (is_nullable) { ^ ``` **be/src/vec/common/schema_util.cpp:564:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp RETURN_IF_ERROR(encode_rowstore()); ^ ``` **be/src/common/status.h:570:** expanded from macro 'RETURN_IF_ERROR' ```cpp do { \ ^ ``` **be/src/vec/common/schema_util.cpp:564:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp RETURN_IF_ERROR(encode_rowstore()); ^ ``` **be/src/common/status.h:572:** expanded from macro 'RETURN_IF_ERROR' ```cpp if (UNLIKELY(!_status_.ok())) { \ ^ ``` </details> ########## be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp: ########## @@ -709,16 +707,127 @@ Status VerticalSegmentWriter::batch_block(const vectorized::Block* block, size_t return Status::OK(); } +// for variant type, we should do following steps to fill content of block: +// 1. set block data to data convertor, and get all flattened columns from variant subcolumns +// 2. get sparse columns from previous sparse columns stripped in OlapColumnDataConvertorVariant +// 3. merge current columns info(contains extracted columns) with previous merged_tablet_schema +// which will be used to contruct the new schema for rowset +Status VerticalSegmentWriter::_append_block_with_variant_subcolumns(RowsInBlock& data) { Review Comment: warning: function '_append_block_with_variant_subcolumns' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp Status VerticalSegmentWriter::_append_block_with_variant_subcolumns(RowsInBlock& data) { ^ ``` <details> <summary>Additional context</summary> **be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp:714:** 98 lines including whitespace and comments (threshold 80) ```cpp Status VerticalSegmentWriter::_append_block_with_variant_subcolumns(RowsInBlock& data) { ^ ``` </details> -- 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