[fix](Nereids): fix bug of converting to NLJ. (#15290)
This commit is contained in:
@ -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())))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user