[fix](nereids) non-slotreference expr in order by lead to plan failed (#14895)

This commit is contained in:
minghong
2022-12-12 00:08:05 +08:00
committed by GitHub
parent f3aea7f0f0
commit 5fe5f596f2

View File

@ -1099,18 +1099,21 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
private TupleDescriptor generateTupleDesc(List<Slot> slotList, List<OrderKey> orderKeyList,
PlanTranslatorContext context, Table table) {
TupleDescriptor tupleDescriptor = context.generateTupleDesc();
tupleDescriptor.setTable(table);
Set<ExprId> alreadyExists = Sets.newHashSet();
tupleDescriptor.setTable(table);
for (OrderKey orderKey : orderKeyList) {
SlotReference slotReference;
if (orderKey.getExpr() instanceof SlotReference) {
SlotReference slotReference = (SlotReference) orderKey.getExpr();
// TODO: trick here, we need semanticEquals to remove redundant expression
if (alreadyExists.contains(slotReference.getExprId())) {
continue;
}
context.createSlotDesc(tupleDescriptor, (SlotReference) orderKey.getExpr());
alreadyExists.add(slotReference.getExprId());
slotReference = (SlotReference) orderKey.getExpr();
} else {
slotReference = (SlotReference) new Alias(orderKey.getExpr(), orderKey.getExpr().toString()).toSlot();
}
// TODO: trick here, we need semanticEquals to remove redundant expression
if (alreadyExists.contains(slotReference.getExprId())) {
continue;
}
context.createSlotDesc(tupleDescriptor, slotReference);
alreadyExists.add(slotReference.getExprId());
}
for (Slot slot : slotList) {
if (alreadyExists.contains(slot.getExprId())) {