Are you aware of the FILTER clause? I believe that COUNT_DISTINCT_IF(x, b) is equivalent to COUNT(DISTINCT x) FILTER(WHERE b). And similarly COUNT_IF and SUM_IF.
FILTER has been in Calcite for a while; I don't know whether it has made it into Kylin yet. Julian > On Aug 28, 2017, at 8:26 AM, Alexander Sterligov <sterligo...@joom.it> wrote: > > Hi! > > I would like to add _if functions to kylin. Could you please help me. > > I already succeeded with count_distinct_if. It was quite easy because > intersect_count is very close to count_distinct_if, I only needed to make > 'factories' and 'udafMap' in MeasureTypeFactory to be multimaps. > > But I have problems with count_if, because BasicMeasureType doesn't have > any rewrite functions and implemented in a different way from other measure > types. There are already some dirty code to handle BasicMeasureType > functions and it looks like new hacks for count_if is not a good idea. It's > better to refactor it to be same for all types and implement count, sum, > min, max as rewrite functions. Am I right? > > > ---------- Forwarded message ---------- > From: Billy Liu <billy...@apache.org> > Date: Mon, Aug 28, 2017 at 5:20 PM > Subject: Re: count_distinct_if, count_if and sum_if > To: user <u...@kylin.apache.org> > > > This kinds of contribution is very welcomed. Could you send your issue to > dev mailer, the community will help you. > > 2017-08-28 21:40 GMT+08:00 Alexander Sterligov <sterligo...@joom.it>: > >> Hi! >> >> It would be nice to have if-functions in kylin. What do you think? >> >> I've already implemented count_distinct_if, but I have problems adding new >> functions for BasicMeasureType. >> >> Best regards, >> Alexander Sterligov >>