[ 
https://issues.apache.org/jira/browse/CALCITE-7362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stamatis Zampetakis resolved CALCITE-7362.
------------------------------------------
    Fix Version/s: 1.42.0
       Resolution: Fixed

Fixed in 
[7654dd82162508231cb3ed44e60fed356e931403|https://github.com/apache/calcite/commit/7654dd82162508231cb3ed44e60fed356e931403].

Thanks for the reviews [~mbudiu] [~zhenchen] and [~asolimando] [~julianhyde] 
for all the feedback and the helpful pointers.

> Add rule to transform WHERE clauses into filtered aggregates
> ------------------------------------------------------------
>
>                 Key: CALCITE-7362
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7362
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>            Reporter: Stamatis Zampetakis
>            Assignee: Stamatis Zampetakis
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.42.0
>
>
> Add a rule to transform aggregate queries with filtering based on {{WHERE}} 
> clauses to filtered aggregates {{AGG(col) FILTER (WHERE)}} without a 
> {{WHERE}} clause.
> The proposed transformation using the SQL representation is shown below:
> +Before+
> {code:sql}
> select sum(ss_net_paid_inc_tax)
> from store_sales
> where ss_quantity < 20
> {code}
> +After+
> {code:sql}
> select sum(ss_net_paid_inc_tax) filter (where ss_quantity < 20) 
> from store_sales; {code}
> The queries are equivalent and the transformation is valid for all aggregate 
> functions.
> The transformation is correct only when there is *no* GROUP BY clause (or 
> GROUP BY ()).
> The main motivation for introducing this rule is view-based rewriting where 
> it is quite common to have multiple conditional aggregates in the same 
> (materialized) view definition for precomputing and reusing expensive 
> aggregations.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to