Skip to content

Commit 63b5a88

Browse files
committed
[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: apache/doris-website#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 -->
1 parent 2aea8f5 commit 63b5a88

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

be/src/olap/rowset/segment_v2/column_reader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <assert.h>
2121
#include <gen_cpp/Descriptors_types.h>
2222
#include <gen_cpp/segment_v2.pb.h>
23+
#include <glog/logging.h>
2324

2425
#include <algorithm>
2526
#include <memory>
@@ -930,6 +931,7 @@ Status ColumnReader::new_struct_iterator(ColumnIteratorUPtr* iterator,
930931
TabletColumn column = tablet_column->get_sub_column(i);
931932
ColumnIteratorUPtr it;
932933
RETURN_IF_ERROR(Segment::new_default_iterator(column, &it));
934+
it->set_column_name(column.name());
933935
sub_column_iterators.emplace_back(std::move(it));
934936
}
935937

regression-test/data/datatype_p0/complex_types/test_pruned_columns.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@
2929
0.41
3030
0.99
3131

32+
-- !sql8 --
33+
\N
34+
added_z
35+

regression-test/suites/datatype_p0/complex_types/test_pruned_columns.groovy

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,37 @@ suite("test_pruned_columns") {
8585
qt_sql7 """
8686
select struct_element(dynamic_attributes['theme_preference'], 'confidence_score') from `tbl_test_pruned_columns_map` order by id;
8787
"""
88+
89+
// test light schema change with nested complex types
90+
sql """
91+
DROP TABLE IF EXISTS nested_sc_tbl;
92+
CREATE TABLE nested_sc_tbl (
93+
`id` BIGINT,
94+
`s_info` STRUCT<a:INT, b:VARCHAR(20)>,
95+
`arr_s` ARRAY<STRUCT<x:INT, y:INT>>,
96+
`map_s` MAP<VARCHAR, STRUCT<m:INT, n:FLOAT>>
97+
)
98+
UNIQUE KEY(`id`)
99+
DISTRIBUTED BY HASH(`id`) BUCKETS 4
100+
PROPERTIES (
101+
"replication_num" = "1",
102+
"light_schema_change" = "true"
103+
);
104+
"""
105+
sql """
106+
ALTER TABLE nested_sc_tbl MODIFY COLUMN s_info STRUCT<a:INT, b:VARCHAR(25), c:INT>;
107+
"""
108+
sql """
109+
INSERT INTO nested_sc_tbl VALUES (1, struct(10, 'v1_struct', 100), array(struct(100, 200)), map('k1', struct(1, 1.1)));
110+
"""
111+
sql """
112+
ALTER TABLE nested_sc_tbl MODIFY COLUMN arr_s ARRAY<STRUCT<x:INT, y:INT, z:VARCHAR(10)>>;
113+
"""
114+
sql """
115+
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)));
116+
"""
117+
118+
qt_sql8 """
119+
select struct_element(element_at(arr_s, 1), 'z') as inner_z FROM nested_sc_tbl ORDER BY id;
120+
"""
88121
}

0 commit comments

Comments
 (0)