use of io.trino.spi.connector.AggregateFunction in project trino by trinodb.
the class TestSqlServerClient method testImplementCount.
@Test
public void testImplementCount() {
Variable bigintVariable = new Variable("v_bigint", BIGINT);
Variable doubleVariable = new Variable("v_double", BIGINT);
Optional<ConnectorExpression> filter = Optional.of(new Variable("a_filter", BOOLEAN));
// count(*)
testImplementAggregation(new AggregateFunction("count", BIGINT, List.of(), List.of(), false, Optional.empty()), Map.of(), Optional.of("count_big(*)"));
// count(bigint)
testImplementAggregation(new AggregateFunction("count", BIGINT, List.of(bigintVariable), List.of(), false, Optional.empty()), Map.of(bigintVariable.getName(), BIGINT_COLUMN), Optional.of("count_big(\"c_bigint\")"));
// count(double)
testImplementAggregation(new AggregateFunction("count", BIGINT, List.of(doubleVariable), List.of(), false, Optional.empty()), Map.of(doubleVariable.getName(), DOUBLE_COLUMN), Optional.of("count_big(\"c_double\")"));
// count(DISTINCT bigint)
testImplementAggregation(new AggregateFunction("count", BIGINT, List.of(bigintVariable), List.of(), true, Optional.empty()), Map.of(bigintVariable.getName(), BIGINT_COLUMN), Optional.empty());
// count() FILTER (WHERE ...)
testImplementAggregation(new AggregateFunction("count", BIGINT, List.of(), List.of(), false, filter), Map.of(), Optional.empty());
// count(bigint) FILTER (WHERE ...)
testImplementAggregation(new AggregateFunction("count", BIGINT, List.of(bigintVariable), List.of(), false, filter), Map.of(bigintVariable.getName(), BIGINT_COLUMN), Optional.empty());
}
use of io.trino.spi.connector.AggregateFunction 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