use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestJoinNodeFlattener method testDoesNotConvertNestedOuterJoins.
@Test
public void testDoesNotConvertNestedOuterJoins() {
PlanBuilder p = planBuilder();
Symbol a1 = p.symbol("A1");
Symbol b1 = p.symbol("B1");
Symbol c1 = p.symbol("C1");
JoinNode leftJoin = p.join(LEFT, p.values(a1), p.values(b1), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
ValuesNode valuesC = p.values(c1);
JoinNode joinNode = p.join(INNER, leftJoin, valuesC, ImmutableList.of(equiJoinClause(a1, c1)), ImmutableList.of(a1, b1, c1), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(leftJoin, valuesC).setFilter(createEqualsExpression(a1, c1, p.getTypes())).setOutputSymbols(a1, b1, c1).setLogicalRowExpressions(logicalRowExpressions).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), DEFAULT_JOIN_LIMIT, queryRunner.getMetadata(), p.getTypes(), logicalRowExpressions), expected);
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestJoinNodeFlattener method testCombinesCriteriaAndFilters.
@Test
public void testCombinesCriteriaAndFilters() {
PlanBuilder p = planBuilder();
Symbol a1 = p.symbol("A1");
Symbol b1 = p.symbol("B1");
Symbol b2 = p.symbol("B2");
Symbol c1 = p.symbol("C1");
Symbol c2 = p.symbol("C2");
ValuesNode valuesA = p.values(a1);
ValuesNode valuesB = p.values(b1, b2);
ValuesNode valuesC = p.values(c1, c2);
RowExpression bcFilter = LogicalRowExpressions.and(p.comparison(OperatorType.GREATER_THAN, p.variable(c2.getName()), constant(0L, BIGINT)), p.comparison(OperatorType.NOT_EQUAL, p.variable(c2.getName()), constant(7L, BIGINT)), p.comparison(OperatorType.GREATER_THAN, p.variable(b2.getName()), p.variable(c2.getName())));
RowExpression abcFilter = p.comparison(OperatorType.LESS_THAN, p.binaryOperation(OperatorType.ADD, p.variable(a1.getName()), p.variable(c1.getName())), p.variable(b1.getName()));
JoinNode joinNode = p.join(INNER, valuesA, p.join(INNER, valuesB, valuesC, ImmutableList.of(equiJoinClause(b1, c1)), ImmutableList.of(b1, b2, c1, c2), Optional.of(bcFilter)), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1, b2, c1, c2), Optional.of(abcFilter));
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestStageStateMachine method createValuesPlan.
private static PlanFragment createValuesPlan() {
Symbol symbol = new Symbol("column");
PlanNodeId valuesNodeId = new PlanNodeId("plan");
PlanFragment planFragment = new PlanFragment(new PlanFragmentId("plan"), new ValuesNode(valuesNodeId, ImmutableList.of(symbol), ImmutableList.of(ImmutableList.of(castToRowExpression(new StringLiteral("foo"))))), ImmutableMap.of(symbol, VARCHAR), SOURCE_DISTRIBUTION, ImmutableList.of(valuesNodeId), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(symbol)), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty(), Optional.empty(), Optional.empty());
return planFragment;
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestEffectivePredicateExtractor method testValues.
@Test
public void testValues() {
TypeProvider types = TypeProvider.copyOf(ImmutableMap.<Symbol, Type>builder().put(A, BIGINT).put(B, BIGINT).build());
// one column
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A), ImmutableList.of(ImmutableList.of(bigintLiteralRowExpression(1)), ImmutableList.of(bigintLiteralRowExpression(2)))), types, typeAnalyzer), new InPredicate(AE, new InListExpression(ImmutableList.of(bigintLiteral(1), bigintLiteral(2)))));
// one column with null
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A), ImmutableList.of(ImmutableList.of(bigintLiteralRowExpression(1)), ImmutableList.of(bigintLiteralRowExpression(2)), ImmutableList.of(castToRowExpression(new Cast(new NullLiteral(), BIGINT.toString()))))), types, typeAnalyzer), or(new InPredicate(AE, new InListExpression(ImmutableList.of(bigintLiteral(1), bigintLiteral(2)))), new IsNullPredicate(AE)));
// all nulls
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A), ImmutableList.of(ImmutableList.of(castToRowExpression(new Cast(new NullLiteral(), BIGINT.toString()))))), types, typeAnalyzer), new IsNullPredicate(AE));
// many rows
List<List<RowExpression>> rows = IntStream.range(0, 500).mapToObj(TestEffectivePredicateExtractor::bigintLiteralRowExpression).map(ImmutableList::of).collect(toImmutableList());
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A), rows), types, typeAnalyzer), new BetweenPredicate(AE, bigintLiteral(0), bigintLiteral(499)));
// multiple columns
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A, B), ImmutableList.of(ImmutableList.of(bigintLiteralRowExpression(1), bigintLiteralRowExpression(100)), ImmutableList.of(bigintLiteralRowExpression(2), bigintLiteralRowExpression(200)))), types, typeAnalyzer), and(new InPredicate(AE, new InListExpression(ImmutableList.of(bigintLiteral(1), bigintLiteral(2)))), new InPredicate(BE, new InListExpression(ImmutableList.of(bigintLiteral(100), bigintLiteral(200))))));
// multiple columns with null
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A, B), ImmutableList.of(ImmutableList.of(bigintLiteralRowExpression(1), castToRowExpression(new Cast(new NullLiteral(), BIGINT.toString()))), ImmutableList.of(castToRowExpression(new Cast(new NullLiteral(), BIGINT.toString())), bigintLiteralRowExpression(200)))), types, typeAnalyzer), and(or(new ComparisonExpression(EQUAL, AE, bigintLiteral(1)), new IsNullPredicate(AE)), or(new ComparisonExpression(EQUAL, BE, bigintLiteral(200)), new IsNullPredicate(BE))));
// non-deterministic
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A, B), ImmutableList.of(ImmutableList.of(bigintLiteralRowExpression(1), castToRowExpression(new FunctionCall(QualifiedName.of("rand"), ImmutableList.of()))))), types, typeAnalyzer), new ComparisonExpression(EQUAL, AE, bigintLiteral(1)));
// non-constant
assertEquals(effectivePredicateExtractor.extract(SESSION, new ValuesNode(newId(), ImmutableList.of(A), ImmutableList.of(ImmutableList.of(bigintLiteralRowExpression(1)), ImmutableList.of(castToRowExpression(BE)))), types, typeAnalyzer), TRUE_LITERAL);
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestDistributedExecutionPlanner method testValuesResume.
@Test
public void testValuesResume() {
ValuesNode a = values("A");
ValuesNode b = values("B");
SubPlan root = makePlan(1, join(a, b), ImmutableList.of());
planner.plan(root, session, RESUME, 5L, 7);
assertEquals(a.getResumeSnapshotId().longValue(), 5);
assertEquals(a.getNextSnapshotId(), 7);
assertEquals(b.getResumeSnapshotId().longValue(), 5);
assertEquals(b.getNextSnapshotId(), 7);
}
Aggregations