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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -985,6 +1008,70 @@ private PlanFragment 
computePhysicalOlapScan(PhysicalOlapScan olapScan, PlanTran
         return planFragment;
     }
 
+    private StorageAlignedScanSlots 
computeStorageAlignedScanSlots(PhysicalOlapScan olapScan) {
+        if (!shouldAlignScanSlotsToStorageSchema(olapScan)) {
+            return new StorageAlignedScanSlots(olapScan.getOutput(), 
Collections.emptySet());
+        }
+
+        Set<ExprId> outputExprIds = olapScan.getOutput().stream()
+                .map(Slot::getExprId)
+                .collect(Collectors.toSet());
+        Map<Integer, Slot> slotByColumnUniqueId = Stream.concat(
+                        olapScan.getSelectedIndexOutputs().stream(), 
olapScan.getOutput().stream())
+                .filter(slot -> ((SlotReference) 
slot).getOriginalColumn().isPresent())
+                .collect(Collectors.toMap(
+                        slot -> ((SlotReference) 
slot).getOriginalColumn().get().getUniqueId(),
+                        slot -> slot,

Review Comment:
   This map cannot be keyed only by `Column.getUniqueId()`. Tables can still 
have `light_schema_change=false` or older metadata before column ids are 
flushed; in that mode `OlapTable.initSchemaColumnUniqueId()` is a no-op and 
every column keeps `Column.COLUMN_UNIQUE_ID_INIT_VALUE` (`-1`). For an 
AGG/non-MOW UNIQUE table with keys `(k1, k2)`, this collector collapses all 
selected-index/output slots under `-1`, so the loop below can resolve both 
storage key columns to the same slot and leave the missing key unfilled. 
Non-direct BE reads then expand `return_columns` to all keys, but 
`origin_return_columns` has no slot for the omitted key, leaving 
`_return_columns_loc` as `-1` and causing wrong column mapping or a crash 
during merge/aggregation. Please keep the existing fallback semantics here: use 
unique id only when it is not `Column.COLUMN_UNIQUE_ID_INIT_VALUE`, otherwise 
match by column name within the selected index, mirroring BE's fallback to 
`field_index(slot->col_name())`.



-- 
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