[Bug](materialized-view) fix not match mv when some alias on agg (#25321)
fix not match mv when some alias on agg
This commit is contained in:
@ -605,16 +605,20 @@ public abstract class AbstractSelectMaterializedIndexRule {
|
||||
}
|
||||
}
|
||||
|
||||
protected List<NamedExpression> generateProjectsAlias(
|
||||
List<? extends NamedExpression> oldProjects, SlotContext slotContext) {
|
||||
protected List<NamedExpression> generateProjectsAlias(List<? extends NamedExpression> oldProjects,
|
||||
SlotContext slotContext) {
|
||||
return oldProjects.stream().map(e -> {
|
||||
Expression real = e;
|
||||
if (real instanceof Alias) {
|
||||
real = real.child(0);
|
||||
}
|
||||
if (slotContext.baseSlotToMvSlot.containsKey(e.toSlot())) {
|
||||
return new Alias(e.getExprId(), slotContext.baseSlotToMvSlot.get(e.toSlot()), e.getName());
|
||||
}
|
||||
if (slotContext.mvNameToMvSlot.containsKey(e.toSql())) {
|
||||
return new Alias(e.getExprId(), slotContext.mvNameToMvSlot.get(e.toSql()), e.getName());
|
||||
if (slotContext.mvNameToMvSlot.containsKey(real.toSql())) {
|
||||
return new Alias(e.getExprId(), slotContext.mvNameToMvSlot.get(real.toSql()), e.getName());
|
||||
}
|
||||
return e;
|
||||
return e.toSlot();
|
||||
}).collect(ImmutableList.toImmutableList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
|
||||
|
||||
if (result.exprRewriteMap.isEmpty()) {
|
||||
return new LogicalProject<>(
|
||||
generateProjectsAlias(agg.getOutput(), slotContext),
|
||||
generateProjectsAlias(agg.getOutputs(), slotContext),
|
||||
new ReplaceExpressions(slotContext).replace(
|
||||
agg.withChildren(
|
||||
project.withProjectsAndChild(
|
||||
|
||||
Reference in New Issue
Block a user