Copilot commented on code in PR #62956:
URL: https://github.com/apache/doris/pull/62956#discussion_r3165272276
##########
be/src/exec/operator/nested_loop_join_probe_operator.cpp:
##########
@@ -573,6 +857,22 @@ Status NestedLoopJoinProbeOperatorX::prepare(RuntimeState*
state) {
}
_num_probe_side_columns = _child->row_desc().num_materialized_slots();
_num_build_side_columns =
_build_side_child->row_desc().num_materialized_slots();
+ for (const auto& conjunct : _join_conjuncts) {
+ conjunct->root()->collect_slot_column_ids(_lazy_eval_column_ids);
+ }
+ if (_has_materialized_slot_ids) {
+ for (const auto slot_id : _materialized_slot_ids) {
+ const int column_id =
intermediate_row_desc().get_column_id(slot_id);
+ DORIS_CHECK(column_id >= 0);
+ _materialize_column_ids.insert(column_id);
+ }
+ }
+ _enable_lazy_materialize =
+ !_old_version_flag && _has_materialized_slot_ids &&
!_is_output_probe_side_only &&
+ !_is_mark_join &&
+ (_join_op == TJoinOp::INNER_JOIN || _join_op ==
TJoinOp::CROSS_JOIN) &&
+ conjuncts().empty() && !projections().empty() &&
+ &projections_row_desc() == &intermediate_row_desc();
Review Comment:
The `&projections_row_desc() == &intermediate_row_desc()` check is a
non-obvious way to assert that projections are evaluated on the intermediate
row descriptor (i.e., no intermediate-output row descriptors were added). This
is fragile/unclear; consider replacing it with a direct, intention-revealing
check (e.g. `_intermediate_output_row_descriptor.empty()` or an equivalent
helper) to avoid subtle issues if these accessors change.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -1992,6 +1992,8 @@ public PlanFragment visitPhysicalNestedLoopJoin(
.flatMap(e -> e.getInputSlots().stream())
.map(SlotReference.class::cast)
.forEach(s -> outputSlotReferenceMap.put(s.getExprId(), s));
+ Map<ExprId, SlotReference> materializedSlotReferenceMap =
Maps.newHashMap(outputSlotReferenceMap);
+ nestedLoopJoinNode.enableMaterializedSlotIds();
Review Comment:
`materializedSlotReferenceMap` is created as a full copy of
`outputSlotReferenceMap` but never diverges from it. This extra allocation/work
during planning seems unnecessary; consider using `outputSlotReferenceMap`
directly (or only creating a separate map if you actually need to mutate it
later).
##########
gensrc/thrift/PlanNodes.thrift:
##########
@@ -1049,6 +1049,11 @@ struct TNestedLoopJoinNode {
9: optional list<Exprs.TExpr> mark_join_conjuncts
// deprecated
10: optional bool use_specific_projections
+
+ // Slots that need to be materialized after join conjunct evaluation.
+ // If this field is not set, BE keeps the legacy behavior.
+ // If this field is set to an empty list, no payload slot needs
materialization.
Review Comment:
The comment here implies that setting `materialized_slot_ids` (including an
empty list) deterministically changes BE materialization behavior, but the
current BE implementation only uses this list under additional constraints
(e.g., inner/cross join + projections-only path). Consider clarifying the IDL
comment to reflect that BE may still fall back to legacy materialization even
when the field is set, and document the exact conditions under which the list
is honored.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]