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/10/12 06:14:00 UTC
[jira] [Commented] (CALCITE-3404) Promote plan for
AggregateExpandDistinctAggregatesRule when all the agg expressions are
distinct and have same arguments
[ https://issues.apache.org/jira/browse/CALCITE-3404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16949920#comment-16949920 ]
Julian Hyde commented on CALCITE-3404:
--------------------------------------
I reviewed your change:
* The term "promote" is not helpful in this case or in the comments you have written in the code. It is more straightforward to say that you can treat an aggregate as if it were distinct.
* The logic for counting the various kinds of aggregate functions was complex, and is now very complex. Can you find a way to refactor it to make it simpler? I don't think a maintainer will understand {{nonDistinctNonIgnoredAggCallCount}}, for instance.
* In RelOptRulesTest, can you use {{sql(sql).with(program).check()}} rather than {{checkPlanning}}. We are moving towards fluent method calls for these kinds of tests; see CALCITE-3327.
> Promote plan for AggregateExpandDistinctAggregatesRule when all the agg expressions are distinct and have same arguments
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-3404
> URL: https://issues.apache.org/jira/browse/CALCITE-3404
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.21.0
> Reporter: Danny Chen
> Assignee: Danny Chen
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.22.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> After CALCITE-3159, the distinct constraint for MAX/MIN/BIT_OR/BIT_AND are removed automatically, so if we have a query:
> {code:sql}
> select sum(distinct deptno), count(distinct deptno), max(deptno) from emp
> {code}
> Than plan has regression from
> {code:xml}
> LogicalAggregate(group=[{}], EXPR$0=[SUM($0)], EXPR$1=[COUNT($0)], EXPR$2=[MAX($0)])
> LogicalAggregate(group=[{0}])
> LogicalProject(DEPTNO=[$7])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> to
> {code:xml}
> LogicalAggregate(group=[{}], EXPR$0=[SUM($0) FILTER $2], EXPR$1=[COUNT($0) FILTER $2], EXPR$2=[MIN($1) FILTER $3])
> LogicalProject(DEPTNO=[$0], EXPR$2=[$1], $g_0=[=($2, 0)], $g_1=[=($2, 1)])
> LogicalAggregate(group=[{0}], groups=[[{0}, {}]], EXPR$2=[MAX($0)], $g=[GROUPING($0)])
> LogicalProject(DEPTNO=[$7])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> The distinct trait actually can be reused.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)