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/04/12 18:20:00 UTC

[jira] [Comment Edited] (CALCITE-2991) getMaxRowCount should return rowcount 1 for an aggregate with constant keys

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

Julian Hyde edited comment on CALCITE-2991 at 4/12/19 6:19 PM:
---------------------------------------------------------------

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.


was (Author: julianhyde):
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)