You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Aman Sinha (JIRA)" <ji...@apache.org> on 2015/02/04 01:20:35 UTC
[jira] [Commented] (DRILL-1842) SELECT COUNT DISTINCT with HAVING
fails to plan the query
[ https://issues.apache.org/jira/browse/DRILL-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14304371#comment-14304371 ]
Aman Sinha commented on DRILL-1842:
-----------------------------------
The CannotPlanException happens because for queries of the form:
{code}
SELECT COUNT(distinct a), COUNT(1) FROM T;
SELECT COUNT(distinct a) FROM T HAVING COUNT(1) > 0;
{code}
Calcite will convert both of these to a cartesian join of 2 subqueries: first subquery produces count(distinct a) and second subquery produces count(1). Currently, cartesian join is not supported in Drill but we should throw a better error message until that is supported.
> SELECT COUNT DISTINCT with HAVING fails to plan the query
> ---------------------------------------------------------
>
> Key: DRILL-1842
> URL: https://issues.apache.org/jira/browse/DRILL-1842
> Project: Apache Drill
> Issue Type: Bug
> Components: Query Planning & Optimization
> Affects Versions: 0.6.0
> Reporter: Chris Matta
> Assignee: Sean Hsuan-Yi Chu
> Fix For: 0.8.0
>
> Attachments: ip-172-16-1-175_drillbit.log
>
>
> Tableau is using the following query to get the distinct count of a measure:
> {code:SQL}
> SELECT COUNT(DISTINCT `custview`.`age`) AS `ctd_age_ok` FROM `mfs.views`.`nestedclickview` `nestedclickview` INNER JOIN `mfs.views`.`custview` `custview` ON (`nestedclickview`.`cust_id` = `custview`.`cust_id`) HAVING (COUNT(1) > 0);
> {code}
> And it fails on 0.06r2 with a planing error.
> Interestingly if I remove the HAVING(COUNT(1)>0) statement at the end it works:
> {code}
> : jdbc:drill:zk=172.16.1.175:5181,172.16.1.1> SELECT COUNT(DISTINCT `custview`.`age`) AS `ctd_age_ok` FROM `mfs.views`.`nestedclickview` `nestedclickview` INNER JOIN `mfs.views`.`custview` `custview` ON (`nestedclickview`.`cust_id` = `custview`.`cust_id`);
> +------------+
> | ctd_age_ok |
> +------------+
> | 5 |
> +------------+
> 1 row selected (4.776 seconds)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)