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

Julian Hyde commented on CALCITE-2991:
--------------------------------------

Regarding a rule to eliminate constant keys. We did this in CALCITE-1023, which 
added {{AggregateConstantKeyRule}}.

It's not {{count(*)}} that will change the semantics. It's removing the last 
group key. Going from {{select 'a', 'b', count(*) from emp group by 'a', 'b'}} 
to {{select 'a', count(*) from emp group by 'a'}} is safe. But going from 
{{select 'a' from emp group by 'a'}} to {{select count(*) from emp group by 
()}} is not safe. The reason is subtle. If emp is empty, the last query will 
return 1 row, but its predecessor will return zero rows.

Yes, it's better to use the rule. But it's also good to have the statistics 
give the right answer if you have not yet applied the rule.

> getMaxRowCount should return rowcount 1 for an aggregate with constant keys
> ---------------------------------------------------------------------------
>
>                 Key: CALCITE-2991
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2991
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Vineet Garg
>            Assignee: Vineet Garg
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Aggregate with constant keys are guaranteed to produce at most one row



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to