use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testInvalidAggregationFunctionCall.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'sum(_[0-9]+)?' is expected to be double, but the actual type is bigint")
public void testInvalidAggregationFunctionCall() throws Exception {
Symbol aggregationSymbol = symbolAllocator.newSymbol("sum", DOUBLE);
Map<Symbol, Signature> functions = ImmutableMap.of(aggregationSymbol, new Signature("sum", FunctionKind.AGGREGATE, ImmutableList.of(), ImmutableList.of(), DOUBLE.getTypeSignature(), ImmutableList.of(DOUBLE.getTypeSignature()), false));
// should be columnC
Map<Symbol, FunctionCall> aggregations = ImmutableMap.of(aggregationSymbol, new FunctionCall(QualifiedName.of("sum"), ImmutableList.of(columnA.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 testValidAggregation.
@Test
public void testValidAggregation() throws Exception {
Symbol aggregationSymbol = symbolAllocator.newSymbol("sum", DOUBLE);
Map<Symbol, Signature> functions = ImmutableMap.of(aggregationSymbol, new Signature("sum", FunctionKind.AGGREGATE, ImmutableList.of(), ImmutableList.of(), DOUBLE.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 testValidUnion.
@Test
public void testValidUnion() throws Exception {
Symbol outputSymbol = symbolAllocator.newSymbol("output", DATE);
ListMultimap<Symbol, Symbol> mappings = ImmutableListMultimap.<Symbol, Symbol>builder().put(outputSymbol, columnD).put(outputSymbol, columnD).build();
PlanNode node = new UnionNode(newId(), ImmutableList.of(baseTableScan, baseTableScan), mappings, ImmutableList.copyOf(mappings.keySet()));
assertTypesValid(node);
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testInvalidUnion.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'output(_[0-9]+)?' is expected to be date, but the actual type is bigint")
public void testInvalidUnion() throws Exception {
Symbol outputSymbol = symbolAllocator.newSymbol("output", DATE);
ListMultimap<Symbol, Symbol> mappings = ImmutableListMultimap.<Symbol, Symbol>builder().put(outputSymbol, columnD).put(outputSymbol, // should be a symbol with DATE type
columnA).build();
PlanNode node = new UnionNode(newId(), ImmutableList.of(baseTableScan, baseTableScan), mappings, ImmutableList.copyOf(mappings.keySet()));
assertTypesValid(node);
}
use of com.facebook.presto.sql.planner.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testSemiJoin.
@Test
public void testSemiJoin() throws Exception {
PlanNode node = new SemiJoinNode(newId(), filter(baseTableScan, and(greaterThan(AE, bigintLiteral(10)), lessThan(AE, bigintLiteral(100)))), filter(baseTableScan, greaterThan(AE, bigintLiteral(5))), A, B, C, Optional.empty(), Optional.empty(), Optional.empty());
Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES);
// Currently, only pull predicates through the source plan
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(and(greaterThan(AE, bigintLiteral(10)), lessThan(AE, bigintLiteral(100)))));
}
Aggregations