[fix](nereids)add visitMarkJoinReference method in ExpressionDeepCopier (#25874)

This commit is contained in:
starocean999
2023-11-03 20:34:29 +08:00
committed by GitHub
parent 8c3e173553
commit 646348ccc4
6 changed files with 40 additions and 12 deletions

View File

@ -276,8 +276,8 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
}
@Override
public Expr visitArrayItemSlot(SlotReference slotReference, PlanTranslatorContext context) {
return context.findColumnRef(slotReference.getExprId());
public Expr visitArrayItemSlot(ArrayItemReference.ArrayItemSlot arrayItemSlot, PlanTranslatorContext context) {
return context.findColumnRef(arrayItemSlot.getExprId());
}
@Override

View File

@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.copier;
import org.apache.doris.nereids.trees.expressions.Alias;
import org.apache.doris.nereids.trees.expressions.ArrayItemReference;
import org.apache.doris.nereids.trees.expressions.Exists;
import org.apache.doris.nereids.trees.expressions.ExprId;
import org.apache.doris.nereids.trees.expressions.Expression;
@ -70,15 +71,14 @@ public class ExpressionDeepCopier extends DefaultExpressionRewriter<DeepCopierCo
@Override
public Expression visitSlotReference(SlotReference slotReference, DeepCopierContext context) {
Map<ExprId, ExprId> exprIdReplaceMap = context.exprIdReplaceMap;
ExprId newExprId;
if (exprIdReplaceMap.containsKey(slotReference.getExprId())) {
ExprId newExprId = exprIdReplaceMap.get(slotReference.getExprId());
return slotReference.withExprId(newExprId);
newExprId = exprIdReplaceMap.get(slotReference.getExprId());
} else {
SlotReference newOne = new SlotReference(slotReference.getName(), slotReference.getDataType(),
slotReference.nullable(), slotReference.getQualifier());
exprIdReplaceMap.put(slotReference.getExprId(), newOne.getExprId());
return newOne;
newExprId = StatementScopeIdGenerator.newExprId();
exprIdReplaceMap.put(slotReference.getExprId(), newExprId);
}
return slotReference.withExprId(newExprId);
}
@Override
@ -105,6 +105,21 @@ public class ExpressionDeepCopier extends DefaultExpressionRewriter<DeepCopierCo
return newOne;
}
@Override
public Expression visitArrayItemReference(ArrayItemReference arrayItemSlot, DeepCopierContext context) {
Expression arrayExpression = arrayItemSlot.getArrayExpression().accept(this, context);
Map<ExprId, ExprId> exprIdReplaceMap = context.exprIdReplaceMap;
ArrayItemReference newOne;
if (exprIdReplaceMap.containsKey(arrayItemSlot.getExprId())) {
newOne = new ArrayItemReference(exprIdReplaceMap.get(arrayItemSlot.getExprId()),
arrayItemSlot.getName(), arrayExpression);
} else {
newOne = new ArrayItemReference(arrayItemSlot.getName(), arrayExpression);
exprIdReplaceMap.put(arrayItemSlot.getExprId(), newOne.getExprId());
}
return newOne;
}
@Override
public Expression visitExistsSubquery(Exists exists, DeepCopierContext context) {
LogicalPlan logicalPlan = LogicalPlanDeepCopier.INSTANCE.deepCopy(exists.getQueryPlan(), context);

View File

@ -129,7 +129,10 @@ public class ArrayItemReference extends NamedExpression implements ExpectsInputT
return ImmutableList.of(ArrayType.of(AnyDataType.INSTANCE_WITHOUT_INDEX));
}
static class ArrayItemSlot extends SlotReference implements SlotNotFromChildren {
/**
* it is slot representation of ArrayItemReference
*/
public static class ArrayItemSlot extends SlotReference implements SlotNotFromChildren {
/**
* Constructor for SlotReference.
*
@ -142,6 +145,11 @@ public class ArrayItemReference extends NamedExpression implements ExpectsInputT
super(exprId, name, dataType, nullable, ImmutableList.of(), null, Optional.empty());
}
@Override
public ArrayItemSlot withExprId(ExprId exprId) {
return new ArrayItemSlot(exprId, name, dataType, nullable);
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitArrayItemSlot(this, context);

View File

@ -221,8 +221,8 @@ public abstract class ExpressionVisitor<R, C>
return visitSlot(slotReference, context);
}
public R visitArrayItemSlot(SlotReference arrayItemSlot, C context) {
return visit(arrayItemSlot, context);
public R visitArrayItemSlot(ArrayItemReference.ArrayItemSlot arrayItemSlot, C context) {
return visitSlotReference(arrayItemSlot, context);
}
public R visitMarkJoinReference(MarkJoinSlotReference markJoinSlotReference, C context) {
@ -434,7 +434,7 @@ public abstract class ExpressionVisitor<R, C>
}
public R visitVirtualReference(VirtualSlotReference virtualSlotReference, C context) {
return visit(virtualSlotReference, context);
return visitSlotReference(virtualSlotReference, context);
}
public R visitArrayItemReference(ArrayItemReference arrayItemReference, C context) {