morrySnow commented on code in PR #39148: URL: https://github.com/apache/doris/pull/39148#discussion_r1714898958
########## fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java: ########## @@ -258,8 +258,35 @@ public PhysicalProperties visitPhysicalHashJoin( // broadcast if (rightOutputProperty.getDistributionSpec() instanceof DistributionSpecReplicated) { - DistributionSpec parentDistributionSpec = leftOutputProperty.getDistributionSpec(); - return new PhysicalProperties(parentDistributionSpec); + DistributionSpec leftDistributionSpec = leftOutputProperty.getDistributionSpec(); + if (hashJoin.child(0).getOutputSet().containsAll(hashJoin.getOutputSet())) { + return new PhysicalProperties(leftDistributionSpec); + } else if (leftDistributionSpec instanceof DistributionSpecHash + && !(hashJoin.isMarkJoin() && hashJoin.getHashJoinConjuncts().isEmpty()) + && !hashJoin.getHashConjunctsExprIds().first.isEmpty() + && !hashJoin.getHashConjunctsExprIds().second.isEmpty() + && hashJoin.getHashConjunctsExprIds().first.size() + == hashJoin.getHashConjunctsExprIds().second.size() + && hashJoin.getHashConjunctsExprIds().first.containsAll( + ((DistributionSpecHash) leftDistributionSpec).getOrderedShuffledColumns())) { Review Comment: should be ```java leftDistributionSpec.satisfy(new DistributionSpecHash(hashJoin.getHashConjunctsExprIds().first, ShuffleType.REQUIRE)) ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java: ########## @@ -258,8 +258,35 @@ public PhysicalProperties visitPhysicalHashJoin( // broadcast if (rightOutputProperty.getDistributionSpec() instanceof DistributionSpecReplicated) { - DistributionSpec parentDistributionSpec = leftOutputProperty.getDistributionSpec(); - return new PhysicalProperties(parentDistributionSpec); + DistributionSpec leftDistributionSpec = leftOutputProperty.getDistributionSpec(); + if (hashJoin.child(0).getOutputSet().containsAll(hashJoin.getOutputSet())) { + return new PhysicalProperties(leftDistributionSpec); + } else if (leftDistributionSpec instanceof DistributionSpecHash + && !(hashJoin.isMarkJoin() && hashJoin.getHashJoinConjuncts().isEmpty()) + && !hashJoin.getHashConjunctsExprIds().first.isEmpty() + && !hashJoin.getHashConjunctsExprIds().second.isEmpty() + && hashJoin.getHashConjunctsExprIds().first.size() + == hashJoin.getHashConjunctsExprIds().second.size() + && hashJoin.getHashConjunctsExprIds().first.containsAll( + ((DistributionSpecHash) leftDistributionSpec).getOrderedShuffledColumns())) { + List<ExprId> leftIds = hashJoin.getHashConjunctsExprIds().first; + List<ExprId> rightIds = hashJoin.getHashConjunctsExprIds().second; + List<ExprId> usedRightExprIds = Lists.newArrayList(); + for (ExprId exprId : ((DistributionSpecHash) leftDistributionSpec).getOrderedShuffledColumns()) { Review Comment: conjuncts expr id may in `EquivalenceSet` -- 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