You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Sean Hsuan-Yi Chu (JIRA)" <ji...@apache.org> on 2015/03/20 00:24:38 UTC

[jira] [Commented] (DRILL-2190) Failure to order by function if DISTINCT clause is present

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

Sean Hsuan-Yi Chu commented on DRILL-2190:
------------------------------------------

Inner distinct is not necessary to reproduce this issue. Besides, I tried this query on the latest calcite master. and it failed also.

Will try to narrow down the issue.

> Failure to order by function if DISTINCT clause is present
> ----------------------------------------------------------
>
>                 Key: DRILL-2190
>                 URL: https://issues.apache.org/jira/browse/DRILL-2190
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 0.8.0
>            Reporter: Victoria Markman
>            Assignee: Sean Hsuan-Yi Chu
>             Fix For: 0.9.0
>
>
> {code}
> 0: jdbc:drill:schema=dfs> select * from t1;
> +------------+------------+------------+
> |     a1     |     b1     |     c1     |
> +------------+------------+------------+
> | 1          | aaaaa      | 2015-01-01 |
> | 2          | bbbbb      | 2015-01-02 |
> | 3          | ccccc      | 2015-01-03 |
> | 4          | null       | 2015-01-04 |
> | 5          | eeeee      | 2015-01-05 |
> | 6          | fffff      | 2015-01-06 |
> | 7          | ggggg      | 2015-01-07 |
> | null       | hhhhh      | 2015-01-08 |
> | 9          | iiiii      | null       |
> | 10         | jjjjj      | 2015-01-10 |
> +------------+------------+------------+
> 10 rows selected (0.092 seconds)
> 0: jdbc:drill:schema=dfs> select distinct count(distinct a1) from t1 group by b1 order by 1;
> Query failed: SqlValidatorException: Expression 'COUNT(`t1`.`a1`)' is not in the select clause
> Error: exception while executing query: Failure while executing query. (state=,code=0)
> {code}
> Replaced ordinal with function: fails
> {code}
> 0: jdbc:drill:schema=dfs> select distinct count(distinct a1) from t1 group by b1 order by count(distinct a1);
> Query failed: SqlValidatorException: Expression 'COUNT(DISTINCT `a1`)' is not in the select clause
> Error: exception while executing query: Failure while executing query. (state=,code=0)
> {code}
> Different aggregate function without DISTINCT clause: fails
> {code}
> 0: jdbc:drill:schema=dfs> select  distinct sum(a1) from t1 group by b1 order by 1;
> Query failed: SqlValidatorException: Expression 'SUM(`t1`.`a1`)' is not in the select clause
> Error: exception while executing query: Failure while executing query. (state=,code=0)
> {code}
> Added alias to the function and order by alias: fails
> {code}
> 0: jdbc:drill:schema=dfs> select  distinct sum(a1) as x from t1 group by b1 order by x;
> Query failed: SqlValidatorException: Expression 'SUM(`t1`.`a1`)' is not in the select clause
> Error: exception while executing query: Failure while executing query. (state=,code=0)
> {code}



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