924060929 commented on code in PR #59006:
URL: https://github.com/apache/doris/pull/59006#discussion_r2650498202


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildrenPropertiesRegulator.java:
##########
@@ -649,19 +667,82 @@ public List<List<PhysicalProperties>> 
visitPhysicalSetOperation(PhysicalSetOpera
         } else if (requiredDistributionSpec instanceof DistributionSpecHash) {
             // TODO: should use the most common hash spec as basic
             DistributionSpecHash basic = (DistributionSpecHash) 
requiredDistributionSpec;
-            for (int i = 0; i < originChildrenProperties.size(); i++) {
-                DistributionSpecHash current
-                        = (DistributionSpecHash) 
originChildrenProperties.get(i).getDistributionSpec();
-                if (current.getShuffleType() != ShuffleType.EXECUTION_BUCKETED
-                        || !bothSideShuffleKeysAreSameOrder(basic, current,
-                        (DistributionSpecHash) 
requiredProperties.get(0).getDistributionSpec(),
-                        (DistributionSpecHash) 
requiredProperties.get(i).getDistributionSpec())) {
+            int distributeToChildIndex = -1;
+            double basicBuckets = -1;
+            double basicRowCount = -1;
+
+            try {
+                ImmutableSet<ShuffleType> supportedShuffleTypes = 
ImmutableSet.of(
+                        ShuffleType.NATURAL,
+                        ShuffleType.STORAGE_BUCKETED
+                );
+                // find the most (bucket num, rowCount) side as the basic
+                for (int i = 0; i < originChildrenProperties.size(); i++) {
+                    PhysicalProperties originChildrenProperty = 
originChildrenProperties.get(i);
+                    DistributionSpec childDistribution = 
originChildrenProperty.getDistributionSpec();
+                    if (childDistribution instanceof DistributionSpecHash
+                            && supportedShuffleTypes.contains(
+                                    ((DistributionSpecHash) 
childDistribution).getShuffleType())) {

Review Comment:
   if not exists NATURAL and STORAGE_BUCKETED, all children must be 
EXECUTION_BUCKETED, and the distributeToChildIndex will be -1, in this case, we 
will use EXECUTION_BUCKETED in [this 
branch](https://github.com/apache/doris/pull/59006/files/634b002f9d3d8bb834725b5c6c8befaa1cbec0e7#diff-79d8abdb9d7855b95a985ffa9b4ddbe1c646b58245fc2d0c02bef33374743777R731-R745)
 



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