xzj7019 commented on code in PR #39148: URL: https://github.com/apache/doris/pull/39148#discussion_r1715303818
########## fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java: ########## @@ -255,11 +255,28 @@ public PhysicalProperties visitPhysicalHashJoin( Preconditions.checkState(childrenOutputProperties.size() == 2); PhysicalProperties leftOutputProperty = childrenOutputProperties.get(0); PhysicalProperties rightOutputProperty = childrenOutputProperties.get(1); + Plan leftChild = hashJoin.child(0); // broadcast if (rightOutputProperty.getDistributionSpec() instanceof DistributionSpecReplicated) { - DistributionSpec parentDistributionSpec = leftOutputProperty.getDistributionSpec(); - return new PhysicalProperties(parentDistributionSpec); + DistributionSpec leftDistributionSpec = leftOutputProperty.getDistributionSpec(); + List<ExprId> leftExprIds = hashJoin.getHashConjunctsExprIds().first; + List<ExprId> rightExprIds = hashJoin.getHashConjunctsExprIds().second; + if (leftChild.getOutputSet().containsAll(hashJoin.getOutputSet())) { + return new PhysicalProperties(leftDistributionSpec); + } else if (leftDistributionSpec instanceof DistributionSpecHash + && !leftExprIds.isEmpty() && !rightExprIds.isEmpty() && leftExprIds.size() == rightExprIds.size()) { + DistributionSpecHash tmpRightHashSpec = new DistributionSpecHash(rightExprIds, ShuffleType.REQUIRE); + if (SessionVariable.canUseNereidsDistributePlanner()) { + return computeShuffleJoinOutputProperties(hashJoin, + (DistributionSpecHash) leftDistributionSpec, tmpRightHashSpec); + } else { + return legacyComputeShuffleJoinOutputProperties(hashJoin, + (DistributionSpecHash) leftDistributionSpec, tmpRightHashSpec); + } Review Comment: done ########## fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java: ########## @@ -255,11 +255,28 @@ public PhysicalProperties visitPhysicalHashJoin( Preconditions.checkState(childrenOutputProperties.size() == 2); PhysicalProperties leftOutputProperty = childrenOutputProperties.get(0); PhysicalProperties rightOutputProperty = childrenOutputProperties.get(1); + Plan leftChild = hashJoin.child(0); // broadcast if (rightOutputProperty.getDistributionSpec() instanceof DistributionSpecReplicated) { - DistributionSpec parentDistributionSpec = leftOutputProperty.getDistributionSpec(); - return new PhysicalProperties(parentDistributionSpec); + DistributionSpec leftDistributionSpec = leftOutputProperty.getDistributionSpec(); + List<ExprId> leftExprIds = hashJoin.getHashConjunctsExprIds().first; + List<ExprId> rightExprIds = hashJoin.getHashConjunctsExprIds().second; + if (leftChild.getOutputSet().containsAll(hashJoin.getOutputSet())) { + return new PhysicalProperties(leftDistributionSpec); + } else if (leftDistributionSpec instanceof DistributionSpecHash + && !leftExprIds.isEmpty() && !rightExprIds.isEmpty() && leftExprIds.size() == rightExprIds.size()) { + DistributionSpecHash tmpRightHashSpec = new DistributionSpecHash(rightExprIds, ShuffleType.REQUIRE); + if (SessionVariable.canUseNereidsDistributePlanner()) { + return computeShuffleJoinOutputProperties(hashJoin, + (DistributionSpecHash) leftDistributionSpec, tmpRightHashSpec); + } else { + return legacyComputeShuffleJoinOutputProperties(hashJoin, + (DistributionSpecHash) leftDistributionSpec, tmpRightHashSpec); + } + } else { + throw new RuntimeException("Could not find hash join's conjuncts: " + hashJoin); + } 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