[fix](Nereids): fix bug of converting to NLJ. (#15290)

This commit is contained in:
jakevin
2022-12-23 19:33:45 +08:00
committed by GitHub
parent ede68e075d
commit 19cc65cc24
3 changed files with 40 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import org.apache.doris.nereids.rules.rewrite.logical.EliminateUnnecessaryProjec
import org.apache.doris.nereids.rules.rewrite.logical.ExtractSingleTableExpressionFromDisjunction;
import org.apache.doris.nereids.rules.rewrite.logical.FindHashConditionForJoin;
import org.apache.doris.nereids.rules.rewrite.logical.InferPredicates;
import org.apache.doris.nereids.rules.rewrite.logical.InnerToCrossJoin;
import org.apache.doris.nereids.rules.rewrite.logical.LimitPushDown;
import org.apache.doris.nereids.rules.rewrite.logical.MergeProjects;
import org.apache.doris.nereids.rules.rewrite.logical.MergeSetOperations;
@ -92,6 +93,7 @@ public class NereidsRewriteJobExecutor extends BatchRulesJob {
.add(topDownBatch(RuleSet.PUSH_DOWN_FILTERS, false))
.add(topDownBatch(ImmutableList.of(PushFilterInsideJoin.INSTANCE)))
.add(topDownBatch(ImmutableList.of(new FindHashConditionForJoin())))
.add(topDownBatch(ImmutableList.of(new InnerToCrossJoin())))
.add(topDownBatch(ImmutableList.of(new EliminateLimit())))
.add(topDownBatch(ImmutableList.of(new EliminateFilter())))
.add(topDownBatch(ImmutableList.of(new PruneOlapScanPartition())))

View File

@ -160,6 +160,7 @@ public enum RuleType {
MERGE_SET_OPERATION(RuleTypeClass.REWRITE),
BUILD_AGG_FOR_UNION(RuleTypeClass.REWRITE),
COUNT_DISTINCT_REWRITE(RuleTypeClass.REWRITE),
INNER_TO_CROSS_JOIN(RuleTypeClass.REWRITE),
REWRITE_SENTINEL(RuleTypeClass.REWRITE),
// limit push down

View File

@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.doris.nereids.rules.rewrite.logical;
import org.apache.doris.nereids.rules.Rule;
import org.apache.doris.nereids.rules.RuleType;
import org.apache.doris.nereids.rules.rewrite.OneRewriteRuleFactory;
import org.apache.doris.nereids.trees.plans.JoinType;
/**
* Convert invalid inner join to cross join.
* Like: A inner join B on true -> A cross join B on true;
*/
public class InnerToCrossJoin extends OneRewriteRuleFactory {
@Override
public Rule build() {
return innerLogicalJoin()
.when(join -> join.getHashJoinConjuncts().size() == 0)
.then(join -> join.withJoinType(JoinType.CROSS_JOIN))
.toRule(RuleType.INNER_TO_CROSS_JOIN);
}
}