[ https://issues.apache.org/jira/browse/CALCITE-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15964086#comment-15964086 ]
radu commented on CALCITE-1740: ------------------------------- I have checked the tests in the RelOptRulesTest class, but i am not sure they help us with this issue. Indeed there are examples of creating Distinct Aggregates (as LogicalAggregates). However, when we would like to work with the aggregates in the over window the process happens in 2 steps First the aggregates are created in a project context and than the ProjectToWindowRule is applied wen the LogicalWindow is created and the aggregation functions are passed. However, the SQLBasicCall which had the distinct aggregate is lost before this point. Also the AggregateCall objects are not created when the logicalWindow is created (just when the isDistinct is called). Therefore if we do not carry the distinct flag in the AggFunction then we would need to add a field in one of the enclosing objects (e.g., in the project and in the logicalwindow) to carry this information until the AggFunction are created. > Distinct aggregate flag in window function > ------------------------------------------ > > Key: CALCITE-1740 > URL: https://issues.apache.org/jira/browse/CALCITE-1740 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: radu > Assignee: Julian Hyde > Labels: build, windows > > When parsing queries such as > SELECT B1, SUM(DISTINCT B2) OVER (ORDER BY B4 RANGE BETWEEN INTERVAL '10' > SECOND PRECEDING AND CURRENT ROW) FROM T > The aggregates in the LogicalWindow do not have any marker of being distinct. > isDistinct() flag is not set. Probably some rule(s) silently swallow the > DISTINCT keyword > The LogicalWindow object that result is > LogicalWindow(window#0=[window(partition {} order by [2] range between $3 > PRECEDING and CURRENT ROW aggs [COUNT($1), $SUM0($1)])]) -- This message was sent by Atlassian JIRA (v6.3.15#6346)