[
https://issues.apache.org/jira/browse/CALCITE-3144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16883432#comment-16883432
]
Julian Hyde commented on CALCITE-3144:
--------------------------------------
I think we're OK. {{allowsFilter}} is true by default (e.g. for {{SUM}} and
{{COUNT}}) and just overridden to false for SINGLE_VALUE, GROUP_ID, etc. I'll
make sure that there is a test for case A1.
{quote}the general idea seems the same as Druid's rule
{quote}
Not a coincidence - I copied Druid's rule, refactored a bit (e.g. removing
Druid-specific type conversions), added tests.
I would imagine that filtered aggregate is fast in several other modern engines
- e.g. Arrow's kerne. It's definitely worth doing.
> Add rule, CaseFilteredAggregatorRule, 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)