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

Julian Hyde commented on CALCITE-3681:
--------------------------------------

Good catch. I think this is a bug. For the query
{code:java}
SELECT a, b, COUNT(*)
FROM t
GROUP BY GROUPING SETS (a), (a, b){code}
I believe that {{areColumnsUnique}} will report that (a, b) is a unique key. 
That is the case if {{b}} is NOT NULL, but not the case if {{b}} allows null 
values.

There are problems with RelMdRowCount too, but they are not as severe because 
it is just an estimate.

Also review how RelMdMinRowCount handles Aggregate.

As ever, be careful with "GROUP BY ()". It returns 1 row even if the table is 
empty. It is counter-intuitive but true that Aggregate sometimes returns more 
rows than it reads. 

> Refine RelMdColumnUniqueness and RelMdRowCount for Aggregate
> ------------------------------------------------------------
>
>                 Key: CALCITE-3681
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3681
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Vladimir Sitnikov
>            Priority: Major
>
> Aggregate might have grouping sets, so 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to