Skip to content

Commit

Permalink
fix regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Oct 8, 2024
1 parent 592694f commit 2e54f74
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -567,9 +568,23 @@ public void computeFd(DataTrait.Builder builder) {

Map<Slot, Slot> constructReplaceMap(MTMV mtmv) {
Map<Slot, Slot> replaceMap = new HashMap<>();
List<Slot> 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<Slot> originOutputs = new ArrayList<>();
for (Slot originSlot : mtmv.getCache().getOriginalPlan().getOutput()) {
if (!(originSlot instanceof SlotReference) || (((SlotReference) originSlot).isVisible())) {
originOutputs.add(originSlot);
}
}
List<Slot> 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;
}
Expand Down

0 comments on commit 2e54f74

Please sign in to comment.