You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2019/07/15 18:04:00 UTC

[jira] [Commented] (CALCITE-3144) Add rule, AggregateCaseToFilterRule, that converts "SUM(CASE WHEN b THEN x END)" to "SUM(x) FILTER (WHERE b)"

    [ https://issues.apache.org/jira/browse/CALCITE-3144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16885460#comment-16885460 ] 

Julian Hyde commented on CALCITE-3144:
--------------------------------------

For a follow-up task, it would be good if {{RelBuilder.aggregate}} was able to do this (if enabled by a flag in {{RelBuilder.Config}}).

One of the deficiencies in the current rule is that it does not remove the CASE expressions from the underlying Project. An approach based on {{RelBuilder}} would not have this limitation. (And {{AggregateExtractProjectRule}} ought to deal with this, but it cannot because it does not fire on {{Project}}, to avoid cycles.)

> Add rule, AggregateCaseToFilterRule, that converts "SUM(CASE WHEN b THEN x END)" to "SUM(x) FILTER (WHERE b)"
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3144
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3144
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>             Fix For: 1.21.0
>
>
> Add a rule that converts "SUM(CASE WHEN b THEN x END)" to "SUM\(x) FILTER (WHERE b)".
> Druid added {{CaseFilteredAggregatorRule}} in https://github.com/apache/incubator-druid/pull/4360.
> Maybe {{AggregateCaseToFilterRule}} is a slightly better name. Or maybe this transform could be done in {{RelBuilder.aggregate}}, and we wouldn't need a rule.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)