[fix](planner) remove input slot for aggregate slot which is not materialized (#32092)
introduced by #26886 run this sql: SELECT caseId FROM ( SELECT caseId, count(judgementDateId) FROM ( SELECT abs(caseId) AS caseId, id as judgementDateId FROM dr_user_test_t2 ) AGG_RESULT GROUP BY caseId ) TOTAL order by 1; will get: ERROR 1105 (HY000): errCode = 2, detailMessage = (172.17.0.1)[INTERNAL_ERROR]couldn't resolve slot descriptor 1, desc: tuples: Tuple(id=5 slots=[Slot(id=10 type=DOUBLE col=-1, colname=, nullable=1), Slot(id=11 type=VARCHAR col=-1, colname=id, nullable=1)] has_varlen_slots=1) Tuple(id=4 slots=[Slot(id=8 type=DOUBLE col=-1, colname=, nullable=1)] has_varlen_slots=0) Tuple(id=2 slots=[Slot(id=4 type=DOUBLE col=-1, colname=caseId, nullable=1)] has_varlen_slots=0) Tuple(id=0 slots=[Slot(id=0 type=VARCHAR col=-1, colname=caseId, nu
This commit is contained in:
@ -24,6 +24,7 @@ import org.apache.doris.analysis.AggregateInfo;
|
||||
import org.apache.doris.analysis.Analyzer;
|
||||
import org.apache.doris.analysis.Expr;
|
||||
import org.apache.doris.analysis.FunctionCallExpr;
|
||||
import org.apache.doris.analysis.SlotDescriptor;
|
||||
import org.apache.doris.analysis.SlotId;
|
||||
import org.apache.doris.analysis.TupleDescriptor;
|
||||
import org.apache.doris.common.NotImplementedException;
|
||||
@ -373,6 +374,16 @@ public class AggregationNode extends PlanNode {
|
||||
result.add(tupleDesc.getMaterializedSlots().get(0).getId());
|
||||
}
|
||||
}
|
||||
// if some input slot for aggregate slot which is not materialized, we need to remove it from the result
|
||||
TupleDescriptor tupleDescriptor = aggInfo.getOutputTupleDesc();
|
||||
ArrayList<SlotDescriptor> slots = tupleDescriptor.getSlots();
|
||||
for (SlotDescriptor slot : slots) {
|
||||
if (!slot.isMaterialized()) {
|
||||
List<SlotId> unRequestIds = Lists.newArrayList();
|
||||
Expr.getIds(slot.getSourceExprs(), null, unRequestIds);
|
||||
unRequestIds.forEach(result::remove);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user