use of org.apache.phoenix.expression.aggregator.CountAggregator in project phoenix by apache.
the class QueryCompilerTest method testCountAggregatorFirst.
@Test
public void testCountAggregatorFirst() throws Exception {
String[] queries = new String[] { "SELECT sum(2.5),organization_id FROM atable GROUP BY organization_id,entity_id", "SELECT avg(a_integer) FROM atable GROUP BY organization_id,substr(entity_id,1,3),entity_id", "SELECT count(a_string) FROM atable GROUP BY substr(organization_id,1),entity_id", "SELECT min('foo') FROM atable GROUP BY entity_id,organization_id", "SELECT min('foo'),sum(a_integer),avg(2.5),4.5,max(b_string) FROM atable GROUP BY substr(organization_id,1),entity_id", "SELECT sum(2.5) FROM atable", "SELECT avg(a_integer) FROM atable", "SELECT count(a_string) FROM atable", "SELECT min('foo') FROM atable LIMIT 5", "SELECT min('foo'),sum(a_integer),avg(2.5),4.5,max(b_string) FROM atable" };
List<Object> binds = Collections.emptyList();
String query = null;
try {
for (int i = 0; i < queries.length; i++) {
query = queries[i];
Scan scan = compileQuery(query, binds);
ServerAggregators aggregators = ServerAggregators.deserialize(scan.getAttribute(BaseScannerRegionObserver.AGGREGATORS), null);
Aggregator aggregator = aggregators.getAggregators()[0];
assertTrue(aggregator instanceof CountAggregator);
}
} catch (Exception e) {
throw new Exception(query, e);
}
}
use of org.apache.phoenix.expression.aggregator.CountAggregator in project phoenix by apache.
the class CountAggregateFunction method newServerAggregator.
@Override
public Aggregator newServerAggregator(Configuration config, ImmutableBytesWritable ptr) {
LongSumAggregator sumAgg = newClientAggregator();
sumAgg.aggregate(null, ptr);
return new CountAggregator(sumAgg);
}
Aggregations