github-actions[bot] commented on code in PR #64010:
URL: https://github.com/apache/doris/pull/64010#discussion_r3377591428


##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -3567,7 +3470,8 @@ bool SegmentIterator::_can_opt_limit_reads() {
 // Before get next batch. make sure all virtual columns in block has type 
ColumnNothing.
 void SegmentIterator::_init_virtual_columns(Block* block) {
     for (const auto& pair : _vir_cid_to_idx_in_block) {
-        auto& col_with_type_and_name = block->get_by_position(pair.second);
+        auto idx = _schema_block_id_map[pair.first];
+        auto& col_with_type_and_name = block->get_by_position(idx);

Review Comment:
   This now indexes the caller block with `_schema_block_id_map`, but this 
block is not guaranteed to use the expanded segment reader schema. In 
merge/non-direct paths `VMergeIteratorContext::block_reset()` builds the block 
from the output schema (`return_columns`) only, and `copy_rows()` also copies 
by output-schema positions. `_schema_block_id_map` is built from `_schema`, 
which can include extra storage-side columns (keys/delete-condition/sequence 
columns) before or around the virtual output column.
   
   A concrete failure case is an output block whose virtual column is at output 
position `pair.second == 0`, while the expanded reader schema maps the same cid 
to position `1`; this code then calls `block->get_by_position(1)` on a 
one-column output block, or targets the wrong output slot. The same layout 
mismatch appears in the EOF/empty-selection virtual-column replacements and 
when `_columns_to_filter` adds virtual columns by 
`_schema_block_id_map[pair.first]`. Please use the output/project block 
position for accesses to caller/output blocks, and keep `_schema_block_id_map` 
only for accesses to blocks that are actually laid out as `_schema`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to