use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testSort.
@Test
public void testSort() throws Exception {
PlanNode node = new SortNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), ImmutableList.of(A), ImmutableMap.of(A, SortOrder.ASC_NULLS_LAST));
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testTopN.
@Test
public void testTopN() throws Exception {
PlanNode node = new TopNNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), 1, ImmutableList.of(A), ImmutableMap.of(A, SortOrder.ASC_NULLS_LAST), true);
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testInvalidProject.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'expr(_[0-9]+)?' is expected to be bigint, but the actual type is integer")
public void testInvalidProject() throws Exception {
Expression expression1 = new Cast(columnB.toSymbolReference(), StandardTypes.INTEGER);
Expression expression2 = new Cast(columnA.toSymbolReference(), StandardTypes.INTEGER);
Assignments assignments = Assignments.builder().put(symbolAllocator.newSymbol(expression1, BIGINT), // should be INTEGER
expression1).put(symbolAllocator.newSymbol(expression1, INTEGER), expression2).build();
PlanNode node = new ProjectNode(newId(), baseTableScan, assignments);
assertTypesValid(node);
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testInvalidAggregationFunctionSignature.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'sum(_[0-9]+)?' is expected to be double, but the actual type is bigint")
public void testInvalidAggregationFunctionSignature() throws Exception {
Symbol aggregationSymbol = symbolAllocator.newSymbol("sum", DOUBLE);
Map<Symbol, Signature> functions = ImmutableMap.of(aggregationSymbol, new Signature("sum", FunctionKind.AGGREGATE, ImmutableList.of(), ImmutableList.of(), // should be DOUBLE
BIGINT.getTypeSignature(), ImmutableList.of(DOUBLE.getTypeSignature()), false));
Map<Symbol, FunctionCall> aggregations = ImmutableMap.of(aggregationSymbol, new FunctionCall(QualifiedName.of("sum"), ImmutableList.of(columnC.toSymbolReference())));
PlanNode node = new AggregationNode(newId(), baseTableScan, aggregations, functions, ImmutableMap.of(), ImmutableList.of(ImmutableList.of(columnA, columnB)), SINGLE, Optional.empty(), Optional.empty());
assertTypesValid(node);
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testValidProject.
@Test
public void testValidProject() throws Exception {
Expression expression1 = new Cast(columnB.toSymbolReference(), StandardTypes.BIGINT);
Expression expression2 = new Cast(columnC.toSymbolReference(), StandardTypes.BIGINT);
Assignments assignments = Assignments.builder().put(symbolAllocator.newSymbol(expression1, BIGINT), expression1).put(symbolAllocator.newSymbol(expression2, BIGINT), expression2).build();
PlanNode node = new ProjectNode(newId(), baseTableScan, assignments);
assertTypesValid(node);
}
Aggregations