Search in sources :

Example 11 with WindowNode

use of io.prestosql.spi.plan.WindowNode in project hetu-core by openlookeng.

the class TestTypeValidator method testInvalidWindowFunctionSignature.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'sum(_[0-9]+)?' is expected to be double, but the actual type is bigint")
public void testInvalidWindowFunctionSignature() {
    Symbol windowSymbol = planSymbolAllocator.newSymbol("sum", DOUBLE);
    // should be DOUBLE
    FunctionHandle functionHandle = FUNCTION_MANAGER.lookupFunction("sum", fromTypes(BIGINT));
    WindowNode.Frame frame = new WindowNode.Frame(WindowFrameType.RANGE, FrameBoundType.UNBOUNDED_PRECEDING, Optional.empty(), FrameBoundType.UNBOUNDED_FOLLOWING, Optional.empty(), Optional.empty(), Optional.empty());
    WindowNode.Function function = new WindowNode.Function(call("sum", functionHandle, BIGINT, ImmutableList.of(VariableReferenceSymbolConverter.toVariableReference(columnC, DOUBLE))), ImmutableList.of(VariableReferenceSymbolConverter.toVariableReference(columnC, DOUBLE)), frame);
    WindowNode.Specification specification = new WindowNode.Specification(ImmutableList.of(), Optional.empty());
    PlanNode node = new WindowNode(newId(), baseTableScan, specification, ImmutableMap.of(windowSymbol, function), Optional.empty(), ImmutableSet.of(), 0);
    assertTypesValid(node);
}
Also used : WindowNode(io.prestosql.spi.plan.WindowNode) PlanNode(io.prestosql.spi.plan.PlanNode) Symbol(io.prestosql.spi.plan.Symbol) FunctionHandle(io.prestosql.spi.function.FunctionHandle) Test(org.testng.annotations.Test)

Aggregations

WindowNode (io.prestosql.spi.plan.WindowNode)11 Symbol (io.prestosql.spi.plan.Symbol)9 FunctionHandle (io.prestosql.spi.function.FunctionHandle)7 PlanNode (io.prestosql.spi.plan.PlanNode)7 Test (org.testng.annotations.Test)6 OrderingScheme (io.prestosql.spi.plan.OrderingScheme)4 FunctionCall (io.prestosql.sql.tree.FunctionCall)4 SortOrder (io.prestosql.spi.block.SortOrder)3 CallExpression (io.prestosql.spi.relation.CallExpression)3 Expression (io.prestosql.sql.tree.Expression)3 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)2 VariableReferenceExpression (io.prestosql.spi.relation.VariableReferenceExpression)2 Type (io.prestosql.spi.type.Type)2 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)2 Optional (java.util.Optional)2 Set (java.util.Set)2 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1