From 2e54f74e35c831d7c0f8ec1077ee88a62f01a97c Mon Sep 17 00:00:00 2001 From: seawinde Date: Tue, 8 Oct 2024 20:30:48 +0800 Subject: [PATCH] fix regression test --- .../trees/plans/logical/LogicalOlapScan.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java index ac986cbe77b6fd..8b6a11180b519e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java @@ -48,6 +48,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.json.JSONObject; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -502,7 +503,7 @@ AGGREGATE KEY (siteid,citycode,username) if (getTable() instanceof MTMV) { MTMV mtmv = (MTMV) getTable(); MTMVCache cache = mtmv.getCache(); - if (cache == null) { + if (cache == null || this.getSelectedIndexId() != this.getTable().getBaseIndexId()) { return; } Plan originalPlan = cache.getOriginalPlan(); @@ -528,7 +529,7 @@ public void computeUniform(DataTrait.Builder builder) { if (getTable() instanceof MTMV) { MTMV mtmv = (MTMV) getTable(); MTMVCache cache = mtmv.getCache(); - if (cache == null) { + if (cache == null || this.getSelectedIndexId() != this.getTable().getBaseIndexId()) { return; } Plan originalPlan = cache.getOriginalPlan(); @@ -542,7 +543,7 @@ public void computeEqualSet(DataTrait.Builder builder) { if (getTable() instanceof MTMV) { MTMV mtmv = (MTMV) getTable(); MTMVCache cache = mtmv.getCache(); - if (cache == null) { + if (cache == null || this.getSelectedIndexId() != this.getTable().getBaseIndexId()) { return; } Plan originalPlan = cache.getOriginalPlan(); @@ -567,9 +568,23 @@ public void computeFd(DataTrait.Builder builder) { Map constructReplaceMap(MTMV mtmv) { Map replaceMap = new HashMap<>(); - List originOutputs = mtmv.getCache().getOriginalPlan().getOutput(); - for (int i = 0; i < getOutput().size(); i++) { - replaceMap.put(originOutputs.get(i), getOutput().get(i)); + // Need remove invisible column, and then mapping them + List originOutputs = new ArrayList<>(); + for (Slot originSlot : mtmv.getCache().getOriginalPlan().getOutput()) { + if (!(originSlot instanceof SlotReference) || (((SlotReference) originSlot).isVisible())) { + originOutputs.add(originSlot); + } + } + List targetOutputs = new ArrayList<>(); + for (Slot targeSlot : getOutput()) { + if (!(targeSlot instanceof SlotReference) || (((SlotReference) targeSlot).isVisible())) { + targetOutputs.add(targeSlot); + } + } + Preconditions.checkArgument(originOutputs.size() == targetOutputs.size(), + "constructReplaceMap, the size of originOutputs and targetOutputs should be same"); + for (int i = 0; i < targetOutputs.size(); i++) { + replaceMap.put(originOutputs.get(i), targetOutputs.get(i)); } return replaceMap; }