No alias being passed to CountAggregatorFactory

Hi All,

Consider the following sample druid query (Datasource : wikipedia) :

select sum(count) as countname,max(delta) as maxdelta, count(added) as countadded from wikipedia where time BETWEEN '2016-02-01 00:00:00' and '2016-02-09 00:00:00' group by country,continent;

For the first two aggregations, their respective factory methods provide constructors which have both column and alias name as arguments.

I have used the following aggregator factories for the first two aggregate functions. I am able to fetch the data from the druid result usingthe alias names passed.

new DoubleSumAggregatorFactory(count,countname);

new DoubleMaxAggregatorFactory(delta,maxdelta);

But for the third aggregation function , count(added), the corresponding factory (CountAggregatorFactory) does not provide a provision for passing the alias. As a result, I am not able to use the same logic of using alias name to fetch the result from the druid result.

Should I be handling count differently? Can someone help me here.

Thanks in advance,
Rajitha


Hey Rajitha,

If you’re wanting a count of the actual number of ingested events, at query time you usually want to be using longSum for this. See “Counting the number of ingested events” here for details: http://druid.io/docs/latest/ingestion/schema-design.html

If you’re wanting to count Druid rows (post-rollup) then CountAggregatorFactory(“foo”) acts like “count(*) as foo”.

Thanks Gian for the response.:slight_smile: