You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Abhishek Girish (JIRA)" <ji...@apache.org> on 2015/04/24 15:48:38 UTC

[jira] [Commented] (DRILL-2317) UNION ALL on sub-queries with single column projection fails on GROUP BY

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

Abhishek Girish commented on DRILL-2317:
----------------------------------------

Verified on Git.Commit.ID a0a1930 (April 21 build)

{code:sql}
SELECT c1
FROM   ((SELECT ss_quantity           AS c1
FROM   store_sales limit 1)
UNION ALL 
(SELECT ws_quantity              AS c2
FROM   web_sales limit 1)
) foo 
GROUP  BY c1;
+------------+
|     c1     |
+------------+
| 79         |
| 57         |
+------------+
2 rows selected (0.744 seconds)

SELECT distinct(c)
FROM   ((SELECT ss_quantity           AS c
FROM   store_sales limit 1)
UNION ALL 
(SELECT ws_quantity              AS c
FROM   web_sales limit 1));
+------------+
|     c      |
+------------+
| 79         |
| 57         |
+------------+
2 rows selected (0.583 seconds)

SELECT x
FROM
(SELECT ss_ext_sales_price x, ss_item_sk w
FROM  store_sales
UNION ALL
SELECT cs_ext_sales_price y, cs_item_sk v
FROM catalog_sales) tmp
GROUP BY x
LIMIT 10;
+------------+
|     x      |
+------------+
| 271.95     |
| 561.2      |
| 391.3      |
| 1821.12    |
| 2125.98    |
| 1695.5     |
| 1513.17    |
| 411.5      |
| 4674.6     |
| 193.08     |
+------------+
10 rows selected (8.868 seconds)
{code}

Results match those from Postgres. 

> UNION ALL on sub-queries with single column projection fails on GROUP BY
> ------------------------------------------------------------------------
>
>                 Key: DRILL-2317
>                 URL: https://issues.apache.org/jira/browse/DRILL-2317
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 0.8.0
>            Reporter: Abhishek Girish
>            Assignee: Sean Hsuan-Yi Chu
>             Fix For: 0.8.0
>
>
> A UNION ALL on two sub-queries with only a single column projected, and GROUP BY on the whole query fails with an IndexOutOfBoundsException
> *The following query fails to execute:*
> {code:sql}
> SELECT c1
> FROM   ((SELECT ss_quantity           AS c1
>         FROM   store_sales limit 1)
>         UNION ALL 
>         (SELECT ws_quantity              AS c2
>         FROM   web_sales limit 1)
>         ) foo 
> GROUP  BY c1;
> {code}
> *The following query also fails to execute:*
> {code:sql}
> SELECT distinct(c)
> FROM   ((SELECT ss_quantity           AS c
>         FROM   store_sales limit 1)
>         UNION ALL 
>         (SELECT ws_quantity              AS c
>         FROM   web_sales limit 1)
>         ) ;
> {code}
> Error:
> Query failed: RemoteRpcException: Failure while running fragment., index: 0, length: 1 (expected: range(0, 0))
> LOG message indicates java.lang.IndexOutOfBoundsException
> *The following query executes fine:*
> {code:sql}
> SELECT c1
> FROM   ((SELECT ss_quantity           AS c1, ss_item_sk c3
>         FROM   store_sales limit 1)
>         UNION ALL 
>         (SELECT ws_quantity              AS c2, ws_item_sk c4
>         FROM   web_sales limit 1)
>         ) foo 
> GROUP  BY c1;
> {code}



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