nooneuse commented on code in PR #66307:
URL: https://github.com/apache/doris/pull/66307#discussion_r3796051010


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java:
##########
@@ -505,6 +515,50 @@ public Void 
visitPhysicalHashAggregate(PhysicalHashAggregate<? extends Plan> agg
         return null;
     }
 
+    private void addColocateMappingRequestForAggregate(PhysicalHashAggregate<? 
extends Plan> agg) {
+        DistributionSpec parentDistribution = 
requestPropertyFromParent.getDistributionSpec();
+        if (connectContext == null
+                || 
!connectContext.getSessionVariable().isEnableColocateMappingConstraint()
+                || agg.hasSourceRepeat()
+                || !(parentDistribution instanceof DistributionSpecHash)
+                || ((DistributionSpecHash) parentDistribution).getShuffleType()
+                        != ShuffleType.COLOCATE_MAPPING_REQUIRE) {
+            return;
+        }
+
+        Map<ExprId, NamedExpression> outputByExprId = 
agg.getOutputExpressions().stream()
+                .collect(Collectors.toMap(NamedExpression::getExprId, output 
-> output, (left, right) -> left));
+        Set<ExprId> groupByExprIds = Sets.newHashSet();
+        for (Expression groupBy : agg.getGroupByExpressions()) {
+            if (!(groupBy instanceof SlotReference)) {
+                return;
+            }
+            groupByExprIds.add(((SlotReference) groupBy).getExprId());
+        }
+        List<ExprId> childRequiredExprIds = Lists.newArrayList();
+        for (ExprId requiredExprId
+                : ((DistributionSpecHash) 
parentDistribution).getOrderedShuffledColumns()) {
+            NamedExpression output = outputByExprId.get(requiredExprId);
+            ExprId childExprId;
+            if (output instanceof Alias && ((Alias) output).child() instanceof 
SlotReference) {

Review Comment:
   yes!



-- 
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]

Reply via email to