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 2015/05/02 04:01:05 UTC

[jira] [Commented] (CALCITE-695) Do not add SINGLE_VALUE aggregate function to a sub-query that will never return more than one row

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

Julian Hyde commented on CALCITE-695:
-------------------------------------

I added some tests for scalar sub-queries in https://git1-us-west.apache.org/repos/asf?p=incubator-calcite.git;a=blob;f=core/src/test/resources/sql/scalar.oq;h=103df2926309e18d380b2bff1e89875ba6287086;hb=f107218b956a1b25d11c8d06c6378bdd22c75378 so I think we're good.

> Do not add SINGLE_VALUE aggregate function to a sub-query that will never return more than one row
> --------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-695
>                 URL: https://issues.apache.org/jira/browse/CALCITE-695
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.3.0-incubating
>            Reporter: Aman Sinha
>            Assignee: Julian Hyde
>             Fix For: 1.3.0-incubating
>
>
> In the following query, the subquery is producing a scalar value but the logical plan still creates a SqlSingleValueAggFunction.   
> {code}
> select r_regionkey from region
>    where r_regionkey > (select min(n_regionkey) * 2 from nation);
> {code}
> If the aggregate is just min(n_regionkey) instead of the expression min(n_regionkey) * 2 then  no SqlSingleValueAggFunction is created.  Ideally, both should behave the same.  
> This is not necessarily a bug but it does create a burden on the underlying execution engine to support this function even in cases where it may not be needed. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)