[fix](Nereids): eliminate redundant join condition after inferring condition (#30093)
eliminate redundant join when find hashing join condition such as for plan: ``` T1 join T2 on T1.id = T2.id join T3 on T1.id = T3.id and T2.id = T3.id ``` we infer a new predicate T1.id = T2.id which is redundant. Therefore we need to eliminate it when find hash condition
This commit is contained in:
@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
|
||||
import org.apache.doris.nereids.util.JoinUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Streams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -61,10 +62,10 @@ public class FindHashConditionForJoin extends OneRewriteRuleFactory {
|
||||
return join;
|
||||
}
|
||||
|
||||
List<Expression> combinedHashJoinConjuncts = new ImmutableList.Builder<Expression>()
|
||||
.addAll(join.getHashJoinConjuncts())
|
||||
.addAll(extractedHashJoinConjuncts)
|
||||
.build();
|
||||
List<Expression> combinedHashJoinConjuncts = Streams
|
||||
.concat(join.getHashJoinConjuncts().stream(), extractedHashJoinConjuncts.stream())
|
||||
.distinct()
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
JoinType joinType = join.getJoinType();
|
||||
if (joinType == JoinType.CROSS_JOIN && !combinedHashJoinConjuncts.isEmpty()) {
|
||||
joinType = JoinType.INNER_JOIN;
|
||||
|
||||
Reference in New Issue
Block a user