This is an automated email from the ASF dual-hosted git repository. mrhhsg pushed a commit to branch cherry-pick-nested_column_prune_4.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 63b5a88a7d1c92a2d42baf0fa4c404159c6c0da2 Author: Jerry Hu <[email protected]> AuthorDate: Wed Dec 3 17:03:58 2025 +0800 [fix](olap) Fix the crash in column pruning caused by the light schema change (#58614) ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Should set the column name of sub-iterator of StructIterator. ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into --> --- be/src/olap/rowset/segment_v2/column_reader.cpp | 2 ++ .../complex_types/test_pruned_columns.out | 4 +++ .../complex_types/test_pruned_columns.groovy | 33 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp b/be/src/olap/rowset/segment_v2/column_reader.cpp index 7c51bc7d082..3ed95016b46 100644 --- a/be/src/olap/rowset/segment_v2/column_reader.cpp +++ b/be/src/olap/rowset/segment_v2/column_reader.cpp @@ -20,6 +20,7 @@ #include <assert.h> #include <gen_cpp/Descriptors_types.h> #include <gen_cpp/segment_v2.pb.h> +#include <glog/logging.h> #include <algorithm> #include <memory> @@ -930,6 +931,7 @@ Status ColumnReader::new_struct_iterator(ColumnIteratorUPtr* iterator, TabletColumn column = tablet_column->get_sub_column(i); ColumnIteratorUPtr it; RETURN_IF_ERROR(Segment::new_default_iterator(column, &it)); + it->set_column_name(column.name()); sub_column_iterators.emplace_back(std::move(it)); } diff --git a/regression-test/data/datatype_p0/complex_types/test_pruned_columns.out b/regression-test/data/datatype_p0/complex_types/test_pruned_columns.out index 870a5763074..86728bafd1c 100644 --- a/regression-test/data/datatype_p0/complex_types/test_pruned_columns.out +++ b/regression-test/data/datatype_p0/complex_types/test_pruned_columns.out @@ -29,3 +29,7 @@ 0.41 0.99 +-- !sql8 -- +\N +added_z + diff --git a/regression-test/suites/datatype_p0/complex_types/test_pruned_columns.groovy b/regression-test/suites/datatype_p0/complex_types/test_pruned_columns.groovy index d54d924e97f..c2a7e2b7146 100644 --- a/regression-test/suites/datatype_p0/complex_types/test_pruned_columns.groovy +++ b/regression-test/suites/datatype_p0/complex_types/test_pruned_columns.groovy @@ -85,4 +85,37 @@ suite("test_pruned_columns") { qt_sql7 """ select struct_element(dynamic_attributes['theme_preference'], 'confidence_score') from `tbl_test_pruned_columns_map` order by id; """ + + // test light schema change with nested complex types + sql """ + DROP TABLE IF EXISTS nested_sc_tbl; + CREATE TABLE nested_sc_tbl ( + `id` BIGINT, + `s_info` STRUCT<a:INT, b:VARCHAR(20)>, + `arr_s` ARRAY<STRUCT<x:INT, y:INT>>, + `map_s` MAP<VARCHAR, STRUCT<m:INT, n:FLOAT>> + ) + UNIQUE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 4 + PROPERTIES ( + "replication_num" = "1", + "light_schema_change" = "true" + ); + """ + sql """ + ALTER TABLE nested_sc_tbl MODIFY COLUMN s_info STRUCT<a:INT, b:VARCHAR(25), c:INT>; + """ + sql """ + INSERT INTO nested_sc_tbl VALUES (1, struct(10, 'v1_struct', 100), array(struct(100, 200)), map('k1', struct(1, 1.1))); + """ + sql """ + ALTER TABLE nested_sc_tbl MODIFY COLUMN arr_s ARRAY<STRUCT<x:INT, y:INT, z:VARCHAR(10)>>; + """ + sql """ + INSERT INTO nested_sc_tbl VALUES (3, struct(30.5, 'v3', 888), array(struct(500, 600, 'added_z'), struct(501, 601, 'added_z_2')), map('k3', struct(3, 3.3))); + """ + + qt_sql8 """ + select struct_element(element_at(arr_s, 1), 'z') as inner_z FROM nested_sc_tbl ORDER BY id; + """ } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
