use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testInvalidUnion.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of variable 'output(_[0-9]+)?' is expected to be date, but the actual type is bigint")
public void testInvalidUnion() {
VariableReferenceExpression output = variableAllocator.newVariable("output", DATE);
PlanNode node = new UnionNode(Optional.empty(), newId(), ImmutableList.of(baseTableScan, baseTableScan), ImmutableList.of(output), ImmutableMap.of(output, ImmutableList.of(variableD, // should be a symbol with DATE type
variableA)));
assertTypesValid(node);
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testInvalidWindowFunctionSignature.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of variable 'sum(_[0-9]+)?' is expected to be double, but the actual type is bigint")
public void testInvalidWindowFunctionSignature() {
VariableReferenceExpression windowVariable = variableAllocator.newVariable("sum", DOUBLE);
// should be DOUBLE
FunctionHandle functionHandle = FUNCTION_MANAGER.lookupFunction("sum", fromTypes(BIGINT));
WindowNode.Frame frame = new WindowNode.Frame(RANGE, UNBOUNDED_PRECEDING, Optional.empty(), UNBOUNDED_FOLLOWING, Optional.empty(), Optional.empty(), Optional.empty());
WindowNode.Function function = new WindowNode.Function(call("sum", functionHandle, BIGINT, variableC), frame, false);
WindowNode.Specification specification = new WindowNode.Specification(ImmutableList.of(), Optional.empty());
PlanNode node = new WindowNode(Optional.empty(), newId(), baseTableScan, specification, ImmutableMap.of(windowVariable, function), Optional.empty(), ImmutableSet.of(), 0);
assertTypesValid(node);
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestTypeValidator method testValidAggregation.
@Test
public void testValidAggregation() {
VariableReferenceExpression aggregationVariable = variableAllocator.newVariable("sum", DOUBLE);
PlanNode node = new AggregationNode(Optional.empty(), newId(), baseTableScan, ImmutableMap.of(aggregationVariable, new Aggregation(new CallExpression("sum", SUM, DOUBLE, ImmutableList.of(variableC)), Optional.empty(), Optional.empty(), false, Optional.empty())), singleGroupingSet(ImmutableList.of(variableA, variableB)), ImmutableList.of(), SINGLE, Optional.empty(), Optional.empty());
assertTypesValid(node);
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testAggregation.
@Test
public void testAggregation() {
PlanNode node = new AggregationNode(Optional.empty(), newId(), filter(baseTableScan, and(equals(AV, DV), equals(BV, EV), equals(CV, FV), lessThan(DV, bigintLiteral(10)), lessThan(CV, DV), greaterThan(AV, bigintLiteral(2)), equals(EV, FV))), ImmutableMap.of(CV, count(metadata.getFunctionAndTypeManager()), DV, count(metadata.getFunctionAndTypeManager())), singleGroupingSet(ImmutableList.of(AV, BV, CV)), ImmutableList.of(), AggregationNode.Step.FINAL, Optional.empty(), Optional.empty());
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
// Rewrite in terms of group by symbols
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(lessThan(AV, bigintLiteral(10)), lessThan(BV, AV), greaterThan(AV, bigintLiteral(2)), equals(BV, CV)));
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testWindow.
@Test
public void testWindow() {
PlanNode node = new WindowNode(Optional.empty(), newId(), filter(baseTableScan, and(equals(AV, BV), equals(BV, CV), lessThan(CV, bigintLiteral(10)))), new WindowNode.Specification(ImmutableList.of(AV), Optional.of(new OrderingScheme(ImmutableList.of(new Ordering(AV, SortOrder.ASC_NULLS_LAST))))), ImmutableMap.of(), Optional.empty(), ImmutableSet.of(), 0);
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(AV, BV), equals(BV, CV), lessThan(CV, bigintLiteral(10))));
}
Aggregations