Search in sources :

Example 1 with FilterJoinRule

use of org.apache.calcite.rel.rules.FilterJoinRule in project calcite by apache.

the class RelOptRulesTest method testPushFilterPastProject.

/**
 * Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-448">[CALCITE-448]
 * FilterIntoJoinRule creates filters containing invalid RexInputRef</a>.
 */
@Test
public void testPushFilterPastProject() {
    final HepProgram preProgram = HepProgram.builder().addRuleInstance(ProjectMergeRule.INSTANCE).build();
    final FilterJoinRule.Predicate predicate = new FilterJoinRule.Predicate() {

        public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
            return joinType != JoinRelType.INNER;
        }
    };
    final FilterJoinRule join = new FilterJoinRule.JoinConditionPushRule(RelBuilder.proto(), predicate);
    final FilterJoinRule filterOnJoin = new FilterJoinRule.FilterIntoJoinRule(true, RelBuilder.proto(), predicate);
    final HepProgram program = HepProgram.builder().addGroupBegin().addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(join).addRuleInstance(filterOnJoin).addGroupEnd().build();
    final String sql = "select a.name\n" + "from dept a\n" + "left join dept b on b.deptno > 10\n" + "right join dept c on b.deptno > 10\n";
    checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
Also used : JoinRelType(org.apache.calcite.rel.core.JoinRelType) HepProgram(org.apache.calcite.plan.hep.HepProgram) Join(org.apache.calcite.rel.core.Join) FilterJoinRule(org.apache.calcite.rel.rules.FilterJoinRule) HepPlanner(org.apache.calcite.plan.hep.HepPlanner) RexNode(org.apache.calcite.rex.RexNode) Test(org.junit.Test)

Aggregations

HepPlanner (org.apache.calcite.plan.hep.HepPlanner)1 HepProgram (org.apache.calcite.plan.hep.HepProgram)1 Join (org.apache.calcite.rel.core.Join)1 JoinRelType (org.apache.calcite.rel.core.JoinRelType)1 FilterJoinRule (org.apache.calcite.rel.rules.FilterJoinRule)1 RexNode (org.apache.calcite.rex.RexNode)1 Test (org.junit.Test)1