[
https://issues.apache.org/jira/browse/CALCITE-6020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17868608#comment-17868608
]
Zoltan Haindrich commented on CALCITE-6020:
-------------------------------------------
seems like I've never updated the ticket about what I have in mind....I do
remember that I've wrote a longer comment but I guess that was lost...
[~zabetak] suggested above to possibly enhance
[AggregateReduceFunctionsRule|https://github.com/apache/calcite/blob/b33dddeb3a79cf4da1ac3c72ae004a893945fc60/core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java#L288]
; which could do the same rewrite and some more for non-windowed aggregates; I
was planning to explore:
* extend that rule to also consider windowed aggregates
* possibly enhance it (if needed) to enable fine grain control whether to
rewrite a given agg call or not
As that's completely different approach - it could be considered independently.
The ability to control the sql2rel level conversion would be also usefull!
> SqlToRelConverter should not replace windowed SUM with equivalent expression
> using SUM0
> ---------------------------------------------------------------------------------------
>
> Key: CALCITE-6020
> URL: https://issues.apache.org/jira/browse/CALCITE-6020
> Project: Calcite
> Issue Type: Improvement
> Reporter: Zoltan Haindrich
> Assignee: Zoltan Haindrich
> Priority: Major
> Labels: pull-request-available
>
> {{SqlToRelConverter}} replaces {{SUM}} with {{SUM0}} around
> [here|https://github.com/apache/calcite/blob/e1991e08a225ef08c2402ab35c310d88fff3c222/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L5885]
> This might have been needed at some point in the past - but I think it will
> be better to leave it as {{SUM}} - as in case there is no {{SUM0}} in the
> system that will be replaced with a {{COALESCE(SUM(...) , 0 )}} to provide it
> - as see
> [here|https://github.com/apache/calcite/blob/e1991e08a225ef08c2402ab35c310d88fff3c222/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java#L1288]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)