Dears

i catch it in the solr adaptor. it is implemented by solr as elasticsearch 
adaptor.


case a: correct
select a, count(distinct b) from tbl group by a;  


case b: incorrect
1. select a, count(distinct b) from tbl where c = 'c' group by a;

2. select a, count(distinct b), max(c)  from tbl group by a; 




attached solr's code


public void implement(Implementor implementor) {
    implementor.visitChild(0, getInput());


    final List<String> inNames = 
SolrRules.solrFieldNames(getInput().getRowType());
    for(Pair<AggregateCall, String> namedAggCall : getNamedAggCalls()) {


      AggregateCall aggCall = namedAggCall.getKey();


      Pair<String, String> metric = toSolrMetric(implementor, aggCall, inNames);
      implementor.addReverseAggMapping(namedAggCall.getValue(), 
metric.getKey().toLowerCase(Locale.ROOT)+"("+metric.getValue()+")");
      implementor.addMetricPair(namedAggCall.getValue(), metric.getKey(), 
metric.getValue());
    }
    ...
}


Best Regards
Haochao Zhuang






------------------ ???????? ------------------
??????: "Michael Mior"<mm...@apache.org>;
????????: 2018??11??13??(??????) ????9:35
??????: "dev"<dev@calcite.apache.org>;

????: Re: count(distinct col) can't recognize distinct



Can you give a specific example of a query that doesn't do what you expect
it to do?

--
Michael Mior
mm...@apache.org


Le mar. 13 nov. 2018 ?? 07:56, ???? <zt...@foxmail.com> a ??crit :

> Hi Guys:
>
>
> I got a question why it can't recognize DISTINCT tag on COUNT(DISTINCT
> col) aggregation function sometimes.
>
>
> but it is not problem when my sql query statement have WHEN clause or one
> more aggregation functions.
>
>
> Best Regards
> Haochao Zhuang

Reply via email to