use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.
the class TestSchedulingOrderVisitor method testSemiJoinOrder.
@Test
public void testSemiJoinOrder() {
PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata());
Symbol sourceJoin = planBuilder.symbol("sourceJoin");
TableScanNode a = planBuilder.tableScan(ImmutableList.of(sourceJoin), ImmutableMap.of(sourceJoin, new TestingColumnHandle("sourceJoin")));
Symbol filteringSource = planBuilder.symbol("filteringSource");
TableScanNode b = planBuilder.tableScan(ImmutableList.of(filteringSource), ImmutableMap.of(filteringSource, new TestingColumnHandle("filteringSource")));
List<PlanNodeId> order = scheduleOrder(planBuilder.semiJoin(sourceJoin, filteringSource, planBuilder.symbol("semiJoinOutput"), Optional.empty(), Optional.empty(), a, b));
assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.
the class TableScanMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
TableScanNode tableScanNode = (TableScanNode) node;
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableScanNode.getTable());
String actualTableName = tableMetadata.getTable().getTableName();
return new MatchResult(expectedTableName.equalsIgnoreCase(actualTableName) && ((!expectedConstraint.isPresent()) || domainsMatch(expectedConstraint, tableScanNode.getEnforcedConstraint(), tableScanNode.getTable(), session, metadata)));
}
use of io.prestosql.spi.plan.TableScanNode in project hetu-core by openlookeng.
the class TestEffectivePredicateExtractor method testTableScan.
@Test
public void testTableScan() {
// Effective predicate is True if there is no effective predicate
Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C, D)));
PlanNode node = TableScanNode.newInstance(newId(), makeTableHandle(TupleDomain.all()), ImmutableList.copyOf(assignments.keySet()), assignments, ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(effectivePredicate, BooleanLiteral.TRUE_LITERAL);
node = new TableScanNode(newId(), makeTableHandle(TupleDomain.none()), ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.none(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(effectivePredicate, FALSE_LITERAL);
TupleDomain<ColumnHandle> predicate = TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(A), Domain.singleValue(BIGINT, 1L)));
node = new TableScanNode(newId(), makeTableHandle(predicate), ImmutableList.copyOf(assignments.keySet()), assignments, predicate, Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(1L), AE)));
predicate = TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(A), Domain.singleValue(BIGINT, 1L), scanAssignments.get(B), Domain.singleValue(BIGINT, 2L)));
node = new TableScanNode(newId(), makeTableHandle(TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(A), Domain.singleValue(BIGINT, 1L)))), ImmutableList.copyOf(assignments.keySet()), assignments, predicate, Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractorWithoutTableProperties.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(bigintLiteral(2L), BE), equals(bigintLiteral(1L), AE)));
node = new TableScanNode(newId(), makeTableHandle(predicate), ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(effectivePredicate, and(equals(AE, bigintLiteral(1)), equals(BE, bigintLiteral(2))));
node = new TableScanNode(newId(), makeTableHandle(predicate), ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(A), Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L)), scanAssignments.get(B), Domain.multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L)))), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(bigintLiteral(2L), BE), equals(bigintLiteral(1L), AE)));
node = new TableScanNode(newId(), makeTableHandle(TupleDomain.all()), ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(effectivePredicate, BooleanLiteral.TRUE_LITERAL);
}
use of io.prestosql.spi.plan.TableScanNode 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.TableScanNode 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))));
}
Aggregations