use of io.prestosql.spi.plan.AggregationNode.Aggregation in project hetu-core by openlookeng.
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() {
Symbol aggregationSymbol = planSymbolAllocator.newSymbol("sum", DOUBLE);
PlanNode node = new AggregationNode(newId(), baseTableScan, ImmutableMap.of(aggregationSymbol, new Aggregation(new CallExpression("sum", SUM, DOUBLE, ImmutableList.of(castToRowExpression(toSymbolReference(columnA)))), ImmutableList.of(castToRowExpression(toSymbolReference(columnA))), false, Optional.empty(), Optional.empty(), Optional.empty())), singleGroupingSet(ImmutableList.of(columnA, columnB)), ImmutableList.of(), SINGLE, Optional.empty(), Optional.empty(), AggregationNode.AggregationType.HASH, Optional.empty());
assertTypesValid(node);
}
use of io.prestosql.spi.plan.AggregationNode.Aggregation in project hetu-core by openlookeng.
the class AggregationFunctionMatcher method getAssignedSymbol.
@Override
public Optional<Symbol> getAssignedSymbol(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases) {
Optional<Symbol> result = Optional.empty();
if (!(node instanceof AggregationNode)) {
return result;
}
AggregationNode aggregationNode = (AggregationNode) node;
FunctionCall expectedCall = callMaker.getExpectedValue(symbolAliases);
for (Map.Entry<Symbol, Aggregation> assignment : aggregationNode.getAggregations().entrySet()) {
Aggregation aggregation = assignment.getValue();
if (aggregationMatches(aggregation, expectedCall, metadata)) {
checkState(!result.isPresent(), "Ambiguous function calls in %s", aggregationNode);
result = Optional.of(assignment.getKey());
}
}
return result;
}
Aggregations