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

Xurenhe edited comment on CALCITE-4983 at 1/13/22, 12:55 PM:
-------------------------------------------------------------

It's great code to fix this bug.
Could you give more no-match test-cases, such as filed of query's condition 
isn't expressed by mv's fields, when aggregate has grouping sets.

I didn't find that this test case exist in the code of master's branch.

Thanks a lot.


was (Author: wojustme):
It's great for fix this bug.
Could you give more no-match test case, such as filed of query's condition 
isn't expressed by mv's fields, when aggregate has grouping sets.

I didn't find that this test case exist in the code of master's branch.

Thanks a lot.

> When using mv rewriting, if aggregate has grouping sets, not handle the 
> query's condition properly.
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4983
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4983
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Ziwei Liu
>            Assignee: Ziwei Liu
>            Priority: Major
>
> In method unifyAggregates, if agg using grouping sets, doesn't handle the 
> condition need to pull up.
> Here is the code:
> {code:java}
> if (targetGroupGenAggCalls.isEmpty()) {
>   List<RexNode> compenProjs = MutableRels.createProjectExprs(target, 
> projects);
>   RexProgram compenRexProgram = RexProgram.create(
>       target.rowType, compenProjs, targetCond, query.rowType, rexBuilder);
>   result = MutableCalc.of(target, compenRexProgram);
> } else {
> // here has a problem: doesn't handle the targetCond
>   result = MutableAggregate.of(target,
>       target.groupSet, target.groupSets, targetGroupGenAggCalls);
> } {code}
> Here is an example:
> {code:java}
> mv: select empid, deptno from emps group by grouping sets ((empid, 
> deptno),(empid))         
> sql: select empid, count(distinct deptno) from emps where empid>100   
>     group by grouping sets ((empid, deptno), (empid)) {code}
> the result plan is:
> {code:java}
> LogicalCalc(expr#0..2=[{inputs}], deptno=[$t1], EXPR$1=[$t2])   
>   LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]], 
> EXPR$1=[COUNT(DISTINCT $1)])  
>     EnumerableTableScan(table=[[hr, MV0]])  {code}
> We can see that this plan doesn't handle the condition empid>100
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to