Kikyou1997 commented on code in PR #11842: URL: https://github.com/apache/doris/pull/11842#discussion_r956611917
########## fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java: ########## @@ -434,28 +432,65 @@ public PlanFragment visitPhysicalProject(PhysicalProject<Plan> project, PlanTran .map(e -> ExpressionTranslator.translate(e, context)) .collect(Collectors.toList()); // TODO: fix the project alias of an aliased relation. + List<Slot> slotList = project.getOutput(); + TupleDescriptor tupleDescriptor = generateTupleDesc(slotList, null, context); PlanNode inputPlanNode = inputFragment.getPlanRoot(); + if (inputPlanNode instanceof HashJoinNode) { + HashJoinNode hashJoinNode = (HashJoinNode) inputPlanNode; + hashJoinNode.setvOutputTupleDesc(tupleDescriptor); + hashJoinNode.setvSrcToOutputSMap(execExprList); + return inputFragment; + } + inputPlanNode.setProjectList(execExprList); + inputPlanNode.setOutputTupleDesc(tupleDescriptor); + List<Expr> predicateList = inputPlanNode.getConjuncts(); Set<Integer> requiredSlotIdList = new HashSet<>(); for (Expr expr : predicateList) { extractExecSlot(expr, requiredSlotIdList); } for (Expr expr : execExprList) { - if (expr instanceof SlotRef) { - requiredSlotIdList.add(((SlotRef) expr).getDesc().getId().asInt()); - } + extractExecSlot(expr, requiredSlotIdList); + } + if (inputPlanNode instanceof OlapScanNode) { + updateChildSlotsMaterialization(inputPlanNode, requiredSlotIdList, context); } return inputFragment; } + private void updateChildSlotsMaterialization(PlanNode execPlan, + Set<Integer> requiredSlotIdList, + PlanTranslatorContext context) { + Set<SlotRef> slotRefSet = new HashSet<>(); + for (Expr expr : execPlan.getConjuncts()) { + expr.collect(SlotRef.class, slotRefSet); + } + Set<Integer> slotIdSet = slotRefSet.stream() + .map(SlotRef::getSlotId).map(SlotId::asInt).collect(Collectors.toSet()); + slotIdSet.addAll(requiredSlotIdList); + execPlan.getTupleIds().stream() + .map(context::getTupleDesc) + .map(TupleDescriptor::getSlots) + .flatMap(List::stream) + .forEach(s -> { + s.setIsMaterialized(slotIdSet.contains(s.getId().asInt())); Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org