wangshuo128 commented on code in PR #15976:
URL: https://github.com/apache/doris/pull/15976#discussion_r1071863398


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -214,12 +215,27 @@ public LogicalOlapScan 
withSelectedPartitionIds(List<Long> selectedPartitionIds)
                 selectedIndexId, indexSelected, preAggStatus, 
manuallySpecifiedPartitions);
     }
 
+    /**
+     * create a logical scan node based on selected index
+     */
     public LogicalOlapScan withMaterializedIndexSelected(PreAggStatus preAgg, 
long indexId) {
-        return new LogicalOlapScan(id, (Table) table, qualifier, 
Optional.empty(), Optional.of(getLogicalProperties()),
+        LogicalProperties newLogicalProperties = new LogicalProperties(
+                Suppliers.ofInstance(getLogicalProperties().getOutput()),
+                Suppliers.ofInstance(
+                        
filterSlotsOfSelectedIndex(getLogicalProperties().getNonUserVisibleOutput(), 
indexId)));
+        return new LogicalOlapScan(id, (Table) table, qualifier, 
Optional.empty(), Optional.of(newLogicalProperties),
                 selectedPartitionIds, partitionPruned, selectedTabletIds, 
tabletPruned,
                 indexId, true, preAgg, manuallySpecifiedPartitions);
     }
 
+    private List<Slot> filterSlotsOfSelectedIndex(List<Slot> slots, long 
indexId) {
+        return slots.stream()
+                .filter(slot -> ((SlotReference) slot).getColumn().isPresent() 
&& getTable()
+                        .getIndexIdToMeta().get(indexId).getSchema()
+                        .contains(((SlotReference) 
slot).getColumn().get())).collect(
+                        Collectors.toList());

Review Comment:
   ```suggestion
           ImmutableSet<Column> selectIndexColumns = ImmutableSet.copyOf(
                   getTable().getIndexIdToMeta().get(indexId).getSchema());
           return slots.stream()
                   .filter(slot -> ((SlotReference) 
slot).getColumn().isPresent()
                           && selectIndexColumns.contains(((SlotReference) 
slot).getColumn().get()))
                   .collect(ImmutableList.toImmutableList());
   ```



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to