jackwener commented on code in PR #10479: URL: https://github.com/apache/doris/pull/10479#discussion_r925393492
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinLAsscom.java: ########## @@ -20,32 +20,130 @@ import org.apache.doris.nereids.rules.Rule; import org.apache.doris.nereids.rules.RuleType; import org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory; -import org.apache.doris.nereids.trees.plans.GroupPlan; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.logical.LogicalJoin; +import org.apache.doris.nereids.util.ExpressionUtils; +import org.apache.doris.nereids.util.Utils; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; /** * Rule for change inner join left associative to right. */ public class JoinLAsscom extends OneExplorationRuleFactory { /* - * topJoin newTopJoin - * / \ / \ - * bottomJoin C --> newBottomJoin B - * / \ / \ - * A B A C + * topJoin newTopJoin + * / \ / \ + * bottomJoin C --> newBottomJoin B + * / \ / \ + * A B A C */ @Override public Rule build() { - return innerLogicalJoin(innerLogicalJoin(), any()).then(topJoin -> { - LogicalJoin<GroupPlan, GroupPlan> bottomJoin = topJoin.left(); + return innerLogicalJoin(innerLogicalJoin(any(), any()), any()).then(topJoin -> { + if (!check(topJoin)) { + return null; + } - GroupPlan a = bottomJoin.left(); - GroupPlan b = bottomJoin.right(); + LogicalJoin<Plan, Plan> bottomJoin = topJoin.left(); + + Plan a = bottomJoin.left(); + Plan b = bottomJoin.right(); Plan c = topJoin.right(); - Plan newBottomJoin = new LogicalJoin(bottomJoin.getJoinType(), bottomJoin.getCondition(), a, c); - return new LogicalJoin(bottomJoin.getJoinType(), topJoin.getCondition(), newBottomJoin, b); + Optional<Expression> optTopJoinOnClause = topJoin.getCondition(); + // inner join, onClause can't be empty(). + Preconditions.checkArgument(optTopJoinOnClause.isPresent(), + "bottomJoin in inner join, onClause must be present."); + Expression topJoinOnClause = optTopJoinOnClause.get(); + Optional<Expression> optBottomJoinOnClause = bottomJoin.getCondition(); + Preconditions.checkArgument(optBottomJoinOnClause.isPresent(), + "bottomJoin in inner join, onClause must be present."); + Expression bottomJoinOnClause = optBottomJoinOnClause.get(); + + List<SlotReference> aOutputSlots = a.getOutput().stream().map(slot -> (SlotReference) slot) Review Comment: Slot just inherit by `UnboundSlot` and `SlotReference` -- 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