use of io.trino.spi.expression.Variable in project trino by trinodb.
the class TestPostgreSqlClient method testImplementSum.
@Test
public void testImplementSum() {
Variable bigintVariable = new Variable("v_bigint", BIGINT);
Variable doubleVariable = new Variable("v_double", DOUBLE);
Optional<ConnectorExpression> filter = Optional.of(new Variable("a_filter", BOOLEAN));
// sum(bigint)
testImplementAggregation(new AggregateFunction("sum", BIGINT, List.of(bigintVariable), List.of(), false, Optional.empty()), Map.of(bigintVariable.getName(), BIGINT_COLUMN), Optional.of("sum(\"c_bigint\")"));
// sum(double)
testImplementAggregation(new AggregateFunction("sum", DOUBLE, List.of(doubleVariable), List.of(), false, Optional.empty()), Map.of(doubleVariable.getName(), DOUBLE_COLUMN), Optional.of("sum(\"c_double\")"));
// sum(DISTINCT bigint)
testImplementAggregation(new AggregateFunction("sum", BIGINT, List.of(bigintVariable), List.of(), true, Optional.empty()), Map.of(bigintVariable.getName(), BIGINT_COLUMN), // distinct not supported
Optional.empty());
// sum(bigint) FILTER (WHERE ...)
testImplementAggregation(new AggregateFunction("sum", BIGINT, List.of(bigintVariable), List.of(), false, filter), Map.of(bigintVariable.getName(), BIGINT_COLUMN), // filter not supported
Optional.empty());
}
Aggregations