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

James Taylor commented on PHOENIX-1749:
---------------------------------------

Thinking a bit more, maybe the safest thing to do for now is to not treat the 
ORDER BY node as an ordinal if the select nodes has any wildcards in it. Just 
create a static boolean hasWildcard(selectNodes) util function in 
OrderByCompiler that returns true if a nodes is an instance of 
WildcardParseNode, FamilyWildcardParseNode, or TableWildcardParseNode. Then 
only enter your new if condition if hasWildcard returns false. In this case, 
you can leave that failing test alone as it should pass after this.

I'll do a little bit of research to see how other databases handle this case. 
The other options aren't too much work.

> ORDER BY should support column position as well as column alias
> ---------------------------------------------------------------
>
>                 Key: PHOENIX-1749
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1749
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Serhiy Bilousov
>            Assignee: Alicia Ying Shu
>         Attachments: PHOENIX-1749-v1.patch, PHOENIX-1749.patch
>
>
> In postgreSQL (and many others DBs) you can specify not only column name for 
> the ORDER BY but column number (position in SELECT part) as well as column 
> alias.
> see:
> http://www.postgresql.org/docs/9.4/static/queries-order.html
> http://www.postgresql.org/docs/9.4/static/sql-select.html#SQL-GROUPBY
> Adding such support would be very helpful and sometimes necessary.
> I can provide real queries example if required but basically we want 
> something like this
> given query
> SELECT a, b, TRUNC(current_date(),'HOUR') AS date_truncated FROM table 
> we want 
> ORDER BY 1 ASC, 2 DESC
> ORDER BY date_truncated 
> Having just column number would cover both but having column alias would make 
> queries more readable and human friendly. Plus make it one little stem closer 
> to postgreSQL and SQL standard.



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

Reply via email to