Search in sources :

Example 6 with JoinNode

use of io.prestosql.spi.plan.JoinNode in project hetu-core by openlookeng.

the class TestDynamicFilterUtil method registerDf.

public static void registerDf(String filterId, Session session, JoinNode.DistributionType joinType, DynamicFilterService dynamicFilterService) {
    JoinNode node = mock(JoinNode.class);
    HashMap<String, Symbol> dfs = new HashMap<>();
    List<JoinNode.EquiJoinClause> criteria = new ArrayList<JoinNode.EquiJoinClause>();
    Symbol right = new Symbol("rightCol");
    Symbol left = new Symbol("leftCol");
    JoinNode.EquiJoinClause clause = new JoinNode.EquiJoinClause(left, right);
    criteria.add(clause);
    dfs.put(filterId, right);
    when(node.getCriteria()).thenReturn(criteria);
    when(node.getDynamicFilters()).thenReturn(dfs);
    when(node.getDistributionType()).thenReturn(Optional.of(joinType));
    RemoteSourceNode leftNode = mock(RemoteSourceNode.class);
    when(node.getLeft()).thenReturn(leftNode);
    HashSet<TaskId> tasks = new HashSet<>();
    tasks.add(new TaskId("task1.0"));
    tasks.add(new TaskId("task1.1"));
    StageStateMachine stateMachine = mock(StageStateMachine.class);
    when(stateMachine.getSession()).thenReturn(session);
    InternalNode worker = mock(InternalNode.class);
    InternalNode worker2 = mock(InternalNode.class);
    HashSet<InternalNode> workers = new HashSet<>();
    when(worker.getNodeIdentifier()).thenReturn("w1");
    when(worker2.getNodeIdentifier()).thenReturn("w2");
    workers.add(worker);
    workers.add(worker2);
    dynamicFilterService.registerTasks(node, tasks, workers, stateMachine);
}
Also used : TaskId(io.prestosql.execution.TaskId) HashMap(java.util.HashMap) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) StageStateMachine(io.prestosql.execution.StageStateMachine) InternalNode(io.prestosql.metadata.InternalNode) HashSet(java.util.HashSet)

Example 7 with JoinNode

use of io.prestosql.spi.plan.JoinNode in project hetu-core by openlookeng.

the class TestEliminateCrossJoins method joinNode.

private JoinNode joinNode(PlanNode left, PlanNode right, String... symbols) {
    checkArgument(symbols.length % 2 == 0);
    ImmutableList.Builder<JoinNode.EquiJoinClause> criteria = ImmutableList.builder();
    for (int i = 0; i < symbols.length; i += 2) {
        criteria.add(new JoinNode.EquiJoinClause(new Symbol(symbols[i]), new Symbol(symbols[i + 1])));
    }
    return new JoinNode(idAllocator.getNextId(), JoinNode.Type.INNER, left, right, criteria.build(), ImmutableList.<Symbol>builder().addAll(left.getOutputSymbols()).addAll(right.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) EquiJoinClause(io.prestosql.spi.plan.JoinNode.EquiJoinClause) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) EquiJoinClause(io.prestosql.spi.plan.JoinNode.EquiJoinClause)

Example 8 with JoinNode

use of io.prestosql.spi.plan.JoinNode in project hetu-core by openlookeng.

the class TestEffectivePredicateExtractor method testInnerJoin.

@Test
public void testInnerJoin() {
    ImmutableList.Builder<JoinNode.EquiJoinClause> criteriaBuilder = ImmutableList.builder();
    criteriaBuilder.add(new JoinNode.EquiJoinClause(A, D));
    criteriaBuilder.add(new JoinNode.EquiJoinClause(B, E));
    List<JoinNode.EquiJoinClause> criteria = criteriaBuilder.build();
    Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C)));
    TableScanNode leftScan = tableScanNode(leftAssignments);
    Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F)));
    TableScanNode rightScan = tableScanNode(rightAssignments);
    FilterNode left = filter(leftScan, and(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), equals(GE, bigintLiteral(10))));
    FilterNode right = filter(rightScan, and(equals(DE, EE), lessThan(FE, bigintLiteral(100))));
    PlanNode node = new JoinNode(newId(), JoinNode.Type.INNER, left, right, criteria, ImmutableList.<Symbol>builder().addAll(left.getOutputSymbols()).addAll(right.getOutputSymbols()).build(), Optional.of(castToRowExpression(lessThanOrEqual(BE, EE))), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of());
    Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
    // All predicates having output symbol should be carried through
    assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), equals(DE, EE), lessThan(FE, bigintLiteral(100)), equals(AE, DE), equals(BE, EE), lessThanOrEqual(BE, EE)));
}
Also used : TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) SemiJoinNode(io.prestosql.sql.planner.plan.SemiJoinNode) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) FilterNode(io.prestosql.spi.plan.FilterNode) PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) CallExpression(io.prestosql.spi.relation.CallExpression) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) InListExpression(io.prestosql.sql.tree.InListExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Expression(io.prestosql.sql.tree.Expression) Test(org.testng.annotations.Test)

Example 9 with JoinNode

use of io.prestosql.spi.plan.JoinNode in project hetu-core by openlookeng.

the class TestEffectivePredicateExtractor method testLeftJoinWithFalseInner.

@Test
public void testLeftJoinWithFalseInner() {
    List<JoinNode.EquiJoinClause> criteria = ImmutableList.of(new JoinNode.EquiJoinClause(A, D));
    Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C)));
    TableScanNode leftScan = tableScanNode(leftAssignments);
    Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F)));
    TableScanNode rightScan = tableScanNode(rightAssignments);
    FilterNode left = filter(leftScan, and(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), equals(GE, bigintLiteral(10))));
    FilterNode right = filter(rightScan, FALSE_LITERAL);
    PlanNode node = new JoinNode(newId(), JoinNode.Type.LEFT, left, right, criteria, ImmutableList.<Symbol>builder().addAll(left.getOutputSymbols()).addAll(right.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of());
    Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
    // False literal on the right side should be ignored
    assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(lessThan(BE, AE), lessThan(CE, bigintLiteral(10)), or(equals(AE, DE), isNull(DE))));
}
Also used : TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) CallExpression(io.prestosql.spi.relation.CallExpression) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) InListExpression(io.prestosql.sql.tree.InListExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Expression(io.prestosql.sql.tree.Expression) SemiJoinNode(io.prestosql.sql.planner.plan.SemiJoinNode) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) FilterNode(io.prestosql.spi.plan.FilterNode) Test(org.testng.annotations.Test)

Example 10 with JoinNode

use of io.prestosql.spi.plan.JoinNode in project hetu-core by openlookeng.

the class TestEffectivePredicateExtractor method testInnerJoinWithFalseFilter.

@Test
public void testInnerJoinWithFalseFilter() {
    Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C)));
    TableScanNode leftScan = tableScanNode(leftAssignments);
    Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F)));
    TableScanNode rightScan = tableScanNode(rightAssignments);
    PlanNode node = new JoinNode(newId(), JoinNode.Type.INNER, leftScan, rightScan, ImmutableList.of(new JoinNode.EquiJoinClause(A, D)), ImmutableList.<Symbol>builder().addAll(leftScan.getOutputSymbols()).addAll(rightScan.getOutputSymbols()).build(), Optional.of(castToRowExpression(FALSE_LITERAL)), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of());
    Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
    assertEquals(effectivePredicate, FALSE_LITERAL);
}
Also used : TestingColumnHandle(io.prestosql.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) CallExpression(io.prestosql.spi.relation.CallExpression) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) InListExpression(io.prestosql.sql.tree.InListExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Expression(io.prestosql.sql.tree.Expression) Symbol(io.prestosql.spi.plan.Symbol) SemiJoinNode(io.prestosql.sql.planner.plan.SemiJoinNode) JoinNode(io.prestosql.spi.plan.JoinNode) Test(org.testng.annotations.Test)

Aggregations

JoinNode (io.prestosql.spi.plan.JoinNode)55 Symbol (io.prestosql.spi.plan.Symbol)44 PlanNode (io.prestosql.spi.plan.PlanNode)31 RowExpression (io.prestosql.spi.relation.RowExpression)22 TableScanNode (io.prestosql.spi.plan.TableScanNode)19 Test (org.testng.annotations.Test)18 FilterNode (io.prestosql.spi.plan.FilterNode)17 ImmutableList (com.google.common.collect.ImmutableList)16 Expression (io.prestosql.sql.tree.Expression)16 ProjectNode (io.prestosql.spi.plan.ProjectNode)15 CallExpression (io.prestosql.spi.relation.CallExpression)14 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)13 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)13 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)13 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)13 Assignments (io.prestosql.spi.plan.Assignments)12 SemiJoinNode (io.prestosql.sql.planner.plan.SemiJoinNode)12 Optional (java.util.Optional)12 Session (io.prestosql.Session)11 List (java.util.List)11