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);
}
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());
}
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)));
}
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))));
}
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);
}
Aggregations