Search in sources :

Example 1 with SemiJoinNode

use of com.facebook.presto.sql.planner.plan.SemiJoinNode in project presto by prestodb.

the class SemiJoinMatcher method detailMatches.

@Override
public MatchResult detailMatches(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases) {
    checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
    SemiJoinNode semiJoinNode = (SemiJoinNode) node;
    if (!(symbolAliases.get(sourceSymbolAlias).equals(semiJoinNode.getSourceJoinSymbol().toSymbolReference()) && symbolAliases.get(filteringSymbolAlias).equals(semiJoinNode.getFilteringSourceJoinSymbol().toSymbolReference()))) {
        return NO_MATCH;
    }
    return match(outputAlias, semiJoinNode.getSemiJoinOutput().toSymbolReference());
}
Also used : SemiJoinNode(com.facebook.presto.sql.planner.plan.SemiJoinNode)

Example 2 with SemiJoinNode

use of com.facebook.presto.sql.planner.plan.SemiJoinNode in project presto by prestodb.

the class TestEffectivePredicateExtractor method testSemiJoin.

@Test
public void testSemiJoin() throws Exception {
    PlanNode node = new SemiJoinNode(newId(), filter(baseTableScan, and(greaterThan(AE, bigintLiteral(10)), lessThan(AE, bigintLiteral(100)))), filter(baseTableScan, greaterThan(AE, bigintLiteral(5))), A, B, C, Optional.empty(), Optional.empty(), Optional.empty());
    Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
    // Currently, only pull predicates through the source plan
    assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(and(greaterThan(AE, bigintLiteral(10)), lessThan(AE, bigintLiteral(100)))));
}
Also used : PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) ComparisonExpression(com.facebook.presto.sql.tree.ComparisonExpression) Expression(com.facebook.presto.sql.tree.Expression) SemiJoinNode(com.facebook.presto.sql.planner.plan.SemiJoinNode) Test(org.testng.annotations.Test)

Example 3 with SemiJoinNode

use of com.facebook.presto.sql.planner.plan.SemiJoinNode in project presto by prestodb.

the class PushLimitThroughSemiJoin method apply.

@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
    if (!(node instanceof LimitNode)) {
        return Optional.empty();
    }
    LimitNode parent = (LimitNode) node;
    PlanNode child = lookup.resolve(parent.getSource());
    if (!(child instanceof SemiJoinNode)) {
        return Optional.empty();
    }
    return Optional.of(transpose(parent, child));
}
Also used : PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) LimitNode(com.facebook.presto.sql.planner.plan.LimitNode) SemiJoinNode(com.facebook.presto.sql.planner.plan.SemiJoinNode)

Example 4 with SemiJoinNode

use of com.facebook.presto.sql.planner.plan.SemiJoinNode in project presto by prestodb.

the class PropertyDerivations method deriveProperties.

public static ActualProperties deriveProperties(PlanNode node, List<ActualProperties> inputProperties, Metadata metadata, Session session, Map<Symbol, Type> types, SqlParser parser) {
    ActualProperties output = node.accept(new Visitor(metadata, session, types, parser), inputProperties);
    // TODO: ideally this logic would be somehow moved to PlanSanityChecker
    verify(node instanceof SemiJoinNode || inputProperties.stream().noneMatch(ActualProperties::isNullsReplicated) || output.isNullsReplicated(), "SemiJoinNode is the only node that can strip null replication");
    return output;
}
Also used : PlanVisitor(com.facebook.presto.sql.planner.plan.PlanVisitor) SemiJoinNode(com.facebook.presto.sql.planner.plan.SemiJoinNode)

Aggregations

SemiJoinNode (com.facebook.presto.sql.planner.plan.SemiJoinNode)4 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)2 LimitNode (com.facebook.presto.sql.planner.plan.LimitNode)1 PlanVisitor (com.facebook.presto.sql.planner.plan.PlanVisitor)1 ComparisonExpression (com.facebook.presto.sql.tree.ComparisonExpression)1 Expression (com.facebook.presto.sql.tree.Expression)1 Test (org.testng.annotations.Test)1