[fix](nereids) the order exprs in sort node should be slotRef in its tupleDesc (#16363)
This commit is contained in:
@ -646,14 +646,10 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
|
||||
outputList.forEach(k -> {
|
||||
sortTupleOutputList.add(ExpressionTranslator.translate(k, context));
|
||||
});
|
||||
// 2. Generate new Tuple
|
||||
TupleDescriptor tupleDesc = generateTupleDesc(outputList, orderKeyList, context, null);
|
||||
// 3. Get current slotRef
|
||||
// 2. Generate new Tuple and get current slotRef for newOrderingExprList
|
||||
List<Expr> newOrderingExprList = Lists.newArrayList();
|
||||
orderKeyList.forEach(k -> {
|
||||
newOrderingExprList.add(ExpressionTranslator.translate(k.getExpr(), context));
|
||||
});
|
||||
// 4. fill in SortInfo members
|
||||
TupleDescriptor tupleDesc = generateTupleDesc(outputList, orderKeyList, newOrderingExprList, context, null);
|
||||
// 3. fill in SortInfo members
|
||||
SortInfo sortInfo = new SortInfo(newOrderingExprList, ascOrderList, nullsFirstParamList, tupleDesc);
|
||||
PlanNode childNode = childFragment.getPlanRoot();
|
||||
SortNode sortNode = new SortNode(context.nextPlanNodeId(), childNode, sortInfo, true);
|
||||
@ -1445,6 +1441,7 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
|
||||
}
|
||||
|
||||
private TupleDescriptor generateTupleDesc(List<Slot> slotList, List<OrderKey> orderKeyList,
|
||||
List<Expr> newOrderingExprList,
|
||||
PlanTranslatorContext context, Table table) {
|
||||
TupleDescriptor tupleDescriptor = context.generateTupleDesc();
|
||||
Set<ExprId> alreadyExists = Sets.newHashSet();
|
||||
@ -1458,9 +1455,11 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
|
||||
}
|
||||
// TODO: trick here, we need semanticEquals to remove redundant expression
|
||||
if (alreadyExists.contains(slotReference.getExprId())) {
|
||||
newOrderingExprList.add(context.findSlotRef(slotReference.getExprId()));
|
||||
continue;
|
||||
}
|
||||
context.createSlotDesc(tupleDescriptor, slotReference);
|
||||
newOrderingExprList.add(context.findSlotRef(slotReference.getExprId()));
|
||||
alreadyExists.add(slotReference.getExprId());
|
||||
}
|
||||
for (Slot slot : slotList) {
|
||||
|
||||
Reference in New Issue
Block a user