[ https://issues.apache.org/jira/browse/DRILL-2190?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Victoria Markman reopened DRILL-2190: ------------------------------------- > 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: 1.2.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)