Skip to content

Commit d8663df

Browse files
branch-4.0: [fix](inverted index) Fix skipping data reads for columns when index is hit #57461 (#57476)
Cherry-picked from #57461 Co-authored-by: Sun Chenyang <sunchenyang@selectdb.com>
1 parent bfae221 commit d8663df

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,12 @@ bool SegmentIterator::_need_read_data(ColumnId cid) {
11901190
// and the operation is a push down of the 'COUNT_ON_INDEX' aggregation function.
11911191
// If any of the above conditions are met, log a debug message indicating that there's no need to read data for the indexed column.
11921192
// Then, return false.
1193-
int32_t unique_id = _opts.tablet_schema->column(cid).unique_id();
1193+
const auto& column = _opts.tablet_schema->column(cid);
1194+
// Different subcolumns may share the same parent_unique_id, so we choose to abandon this optimization.
1195+
if (column.is_extracted_column()) {
1196+
return true;
1197+
}
1198+
int32_t unique_id = column.unique_id();
11941199
if ((_need_read_data_indices.contains(cid) && !_need_read_data_indices[cid] &&
11951200
!_output_columns.contains(unique_id)) ||
11961201
(_need_read_data_indices.contains(cid) && !_need_read_data_indices[cid] &&

regression-test/data/variant_p0/predefine/test_predefine_type_index.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,9 @@
7171
-- !sql --
7272
20
7373

74+
-- !sql --
75+
Bright Red
76+
77+
-- !sql --
78+
Bright Red
79+

regression-test/suites/variant_p0/predefine/test_predefine_type_index.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,7 @@ suite("test_variant_predefine_index_type", "p0"){
107107
trigger_and_wait_compaction(tableName, "cumulative")
108108
sql "set enable_match_without_inverted_index = false"
109109
qt_sql "select count() from objects where (overflow_properties['color'] MATCH_PHRASE 'Blue')"
110-
qt_sql "select count() from objects where (array_contains(cast(overflow_properties['tags'] as array<string>), 'plastic'))"
110+
qt_sql "select count() from objects where (array_contains(cast(overflow_properties['tags'] as array<string>), 'plastic'))"
111+
qt_sql "select cast(overflow_properties['color'] as string) from objects where overflow_properties['color'] IS NOT NULL and id = 6 limit 1"
112+
qt_sql "select overflow_properties['color'] from objects where overflow_properties['color'] IS NOT NULL and id = 6 limit 1"
111113
}

0 commit comments

Comments
 (0)