|
30 | 30 | import org.apache.doris.nereids.trees.expressions.SlotReference; |
31 | 31 | import org.apache.doris.nereids.trees.expressions.functions.agg.MultiDistinction; |
32 | 32 | import org.apache.doris.nereids.trees.plans.AggMode; |
| 33 | +import org.apache.doris.nereids.trees.plans.JoinType; |
33 | 34 | import org.apache.doris.nereids.trees.plans.Plan; |
34 | 35 | import org.apache.doris.nereids.trees.plans.SortPhase; |
35 | 36 | import org.apache.doris.nereids.trees.plans.physical.AbstractPhysicalSort; |
@@ -178,6 +179,12 @@ public Boolean visitPhysicalFilter(PhysicalFilter<? extends Plan> filter, Void c |
178 | 179 | return true; |
179 | 180 | } |
180 | 181 |
|
| 182 | + private boolean couldNotRightBucketShuffleJoin(JoinType joinType) { |
| 183 | + return joinType == JoinType.RIGHT_ANTI_JOIN |
| 184 | + || joinType == JoinType.RIGHT_OUTER_JOIN |
| 185 | + || joinType == JoinType.FULL_OUTER_JOIN; |
| 186 | + } |
| 187 | + |
181 | 188 | @Override |
182 | 189 | public Boolean visitPhysicalHashJoin(PhysicalHashJoin<? extends Plan, ? extends Plan> hashJoin, |
183 | 190 | Void context) { |
@@ -207,12 +214,22 @@ public Boolean visitPhysicalHashJoin(PhysicalHashJoin<? extends Plan, ? extends |
207 | 214 | Optional<PhysicalProperties> updatedForLeft = Optional.empty(); |
208 | 215 | Optional<PhysicalProperties> updatedForRight = Optional.empty(); |
209 | 216 |
|
210 | | - if ((leftHashSpec.getShuffleType() == ShuffleType.NATURAL |
211 | | - && rightHashSpec.getShuffleType() == ShuffleType.NATURAL)) { |
| 217 | + if (JoinUtils.couldColocateJoin(leftHashSpec, rightHashSpec)) { |
212 | 218 | // check colocate join with scan |
213 | | - if (JoinUtils.couldColocateJoin(leftHashSpec, rightHashSpec)) { |
214 | | - return true; |
215 | | - } |
| 219 | + return true; |
| 220 | + } else if (couldNotRightBucketShuffleJoin(hashJoin.getJoinType())) { |
| 221 | + // right anti, right outer, full outer join could not do bucket shuffle join |
| 222 | + // TODO remove this after we refactor coordinator |
| 223 | + updatedForLeft = Optional.of(calAnotherSideRequired( |
| 224 | + ShuffleType.EXECUTION_BUCKETED, leftHashSpec, leftHashSpec, |
| 225 | + (DistributionSpecHash) requiredProperties.get(0).getDistributionSpec(), |
| 226 | + (DistributionSpecHash) requiredProperties.get(0).getDistributionSpec())); |
| 227 | + updatedForRight = Optional.of(calAnotherSideRequired( |
| 228 | + ShuffleType.EXECUTION_BUCKETED, leftHashSpec, rightHashSpec, |
| 229 | + (DistributionSpecHash) requiredProperties.get(0).getDistributionSpec(), |
| 230 | + (DistributionSpecHash) requiredProperties.get(1).getDistributionSpec())); |
| 231 | + } else if ((leftHashSpec.getShuffleType() == ShuffleType.NATURAL |
| 232 | + && rightHashSpec.getShuffleType() == ShuffleType.NATURAL)) { |
216 | 233 | updatedForRight = Optional.of(calAnotherSideRequired( |
217 | 234 | ShuffleType.STORAGE_BUCKETED, leftHashSpec, rightHashSpec, |
218 | 235 | (DistributionSpecHash) requiredProperties.get(0).getDistributionSpec(), |
|
0 commit comments