Search in sources :

Example 1 with PredicatePushDown

use of com.facebook.presto.sql.planner.optimizations.PredicatePushDown in project presto by prestodb.

the class TestPredicatePushdown method testPredicatePushDownCreatesValidJoin.

@Test
public void testPredicatePushDownCreatesValidJoin() {
    RuleTester tester = new RuleTester();
    tester.assertThat(new PredicatePushDown(tester.getMetadata(), tester.getSqlParser())).on(p -> p.join(INNER, p.filter(p.comparison(OperatorType.EQUAL, p.variable("a1"), constant(1L, INTEGER)), p.values(p.variable("a1"))), p.values(p.variable("b1")), ImmutableList.of(new EquiJoinClause(p.variable("a1"), p.variable("b1"))), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PARTITIONED), ImmutableMap.of())).matches(project(join(INNER, ImmutableList.of(), Optional.empty(), Optional.of(REPLICATED), project(filter("a1=1", values("a1"))), project(filter("1=b1", values("b1"))))));
}
Also used : EquiJoinClause(com.facebook.presto.sql.planner.plan.JoinNode.EquiJoinClause) PlanOptimizer(com.facebook.presto.sql.planner.optimizations.PlanOptimizer) PlanMatchPattern.filter(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.filter) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) PredicatePushDown(com.facebook.presto.sql.planner.optimizations.PredicatePushDown) PlanMatchPattern.anyTree(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.anyTree) PlanMatchPattern.output(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.output) PlanMatchPattern.assignUniqueId(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.assignUniqueId) Test(org.testng.annotations.Test) Expressions.constant(com.facebook.presto.sql.relational.Expressions.constant) PlanMatchPattern(com.facebook.presto.sql.planner.assertions.PlanMatchPattern) PlanMatchPattern.join(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.join) ImmutableList(com.google.common.collect.ImmutableList) PlanMatchPattern.equiJoinClause(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.equiJoinClause) Map(java.util.Map) PlanMatchPattern.expression(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.expression) PlanMatchPattern.project(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project) WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) ImmutableMap(com.google.common.collect.ImmutableMap) PlanMatchPattern.semiJoin(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.semiJoin) PlanMatchPattern.tableScan(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.tableScan) PlanMatchPattern.exchange(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.exchange) OperatorType(com.facebook.presto.common.function.OperatorType) List(java.util.List) REPLICATED(com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.REPLICATED) LEFT(com.facebook.presto.sql.planner.plan.JoinNode.Type.LEFT) INTEGER(com.facebook.presto.common.type.IntegerType.INTEGER) Optional(java.util.Optional) PlanMatchPattern.values(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values) PARTITIONED(com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.PARTITIONED) RuleTester(com.facebook.presto.sql.planner.iterative.rule.test.RuleTester) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) PlanMatchPattern.node(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.node) INNER(com.facebook.presto.sql.planner.plan.JoinNode.Type.INNER) RuleTester(com.facebook.presto.sql.planner.iterative.rule.test.RuleTester) EquiJoinClause(com.facebook.presto.sql.planner.plan.JoinNode.EquiJoinClause) PredicatePushDown(com.facebook.presto.sql.planner.optimizations.PredicatePushDown) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Aggregations

OperatorType (com.facebook.presto.common.function.OperatorType)1 INTEGER (com.facebook.presto.common.type.IntegerType.INTEGER)1 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)1 PlanMatchPattern (com.facebook.presto.sql.planner.assertions.PlanMatchPattern)1 PlanMatchPattern.anyTree (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.anyTree)1 PlanMatchPattern.assignUniqueId (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.assignUniqueId)1 PlanMatchPattern.equiJoinClause (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.equiJoinClause)1 PlanMatchPattern.exchange (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.exchange)1 PlanMatchPattern.expression (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.expression)1 PlanMatchPattern.filter (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.filter)1 PlanMatchPattern.join (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.join)1 PlanMatchPattern.node (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.node)1 PlanMatchPattern.output (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.output)1 PlanMatchPattern.project (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project)1 PlanMatchPattern.semiJoin (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.semiJoin)1 PlanMatchPattern.tableScan (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.tableScan)1 PlanMatchPattern.values (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values)1 RuleTester (com.facebook.presto.sql.planner.iterative.rule.test.RuleTester)1 PlanOptimizer (com.facebook.presto.sql.planner.optimizations.PlanOptimizer)1 PredicatePushDown (com.facebook.presto.sql.planner.optimizations.PredicatePushDown)1