[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) {
|
||||
|
||||
@ -125,6 +125,7 @@ suite("test_join_nereids") {
|
||||
sql 'set enable_vectorized_engine=true;'
|
||||
sql 'set enable_fallback_to_original_planner=false;'
|
||||
sql 'set enable_nereids_planner=true;'
|
||||
sql 'set parallel_fragment_exec_instance_num = 2;'
|
||||
|
||||
qt_agg_sql1 """select /*+SET_VAR(disable_nereids_rules='TWO_PHASE_AGGREGATE_WITH_COUNT_DISTINCT_MULTI')*/ count(distinct k1, NULL) from test;"""
|
||||
qt_agg_sql2 """select /*+SET_VAR(disable_nereids_rules='TWO_PHASE_AGGREGATE_WITH_COUNT_DISTINCT_MULTI')*/ count(distinct k1, NULL), avg(k2) from baseall;"""
|
||||
@ -285,9 +286,11 @@ suite("test_join_nereids") {
|
||||
on a.k1 = b.k1 and a.k2 > 0 order by 1, isnull(b.k1), 2, 3, 4, 5 limit 65535"""
|
||||
qt_left_join2"""select ${i} from ${tbName1} a left join ${tbName2} b
|
||||
on a.k1 = b.k1 and a.k2 > b.k2 order by 1, isnull(b.k1), 2, 3, 4, 5 limit 65535"""
|
||||
sql 'set batch_size = 3;'
|
||||
qt_left_join3"""select ${i} from ${tbName1} a left join ${tbName2} b on a.k2 = b.k2 and a.k1 > 0
|
||||
left join ${tbName3} c on a.k3 = c.k3 and b.k1 = c.k1 + 1 and c.k3 > 0
|
||||
order by 1, isnull(b.k1), 2, 3, 4, 5 limit 65535"""
|
||||
sql 'set batch_size = 4064;'
|
||||
|
||||
for (s in selected) {
|
||||
qt_left_join4"""select ${s} from ${tbName1} a left join ${tbName2} b
|
||||
|
||||
Reference in New Issue
Block a user