Calcite doesn’t currently support distinct aggregates in window functions. See 
https://issues.apache.org/jira/browse/CALCITE-476 
<https://issues.apache.org/jira/browse/CALCITE-476>. 

That said, it shouldn’t silently swallow the DISTINCT keyword. It should give 
an error. I suspect that some rule is ignoring the distinct flag. Can you log a 
JIRA case please?

Julian


> On Apr 4, 2017, at 9:46 AM, Radu Tudoran <[email protected]> wrote:
> 
> Hi,
> 
> I am trying to parse the logical query plan that results after executing 
> queries such as:
> 
> SELECT B1, SUM(DISTINCT B2) OVER  (ORDER BY  B4 RANGE BETWEEN INTERVAL '10' 
> SECOND PRECEDING AND CURRENT ROW) FROM T
> 
> However, when I look in the list of the aggregates from the LogicalWindow, 
> the Aggregate does not have any marker of being distinct. I also checked the 
> isDistinct() and it returns false for the aggregate.
> 
> .. I get as LogicalWindow object
> LogicalWindow(window#0=[window(partition {} order by [2] range between $3 
> PRECEDING and CURRENT ROW aggs [COUNT($1), $SUM0($1)])])
> 
> Moreover if I run a query that has a count and a count distinct over a window 
> it will be simplified to a single count aggregate.
> 
> Am I missing something or is there a bug?
> 
> Best regards,
> 
> Radu
> 

Reply via email to