[
https://issues.apache.org/jira/browse/PHOENIX-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14485986#comment-14485986
]
James Taylor commented on PHOENIX-1749:
---------------------------------------
I think the approach I outlined here, at the ParseNode level, is the best
approach without making a lot of changes to
TrackOrderPreservingExpressionCompiler:
https://issues.apache.org/jira/browse/PHOENIX-1749?focusedCommentId=14393862&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14393862
TrackOrderPreservingExpressionCompiler is trying to determine if the ORDER BY
will return rows in row key order for the table being scanned. If you take the
approach of working from an Expression, you're bypassing the logic in
TrackOrderPreservingExpressionCompiler. This is particularly problematic for
cases where Expression is not just a column name, but some kind of more
complicated logic.
A bigger change would be to implement an Expression visitor instead of a
ParseNode visitor to determine if the ORDER BY expression maintain row key
order, but that's a bigger, more involved task. Safer to take the above
mentioned path and not interfer with the logic of
TrackOrderPreservingExpressionCompiler.
> ORDER BY should support ordinal position as well as expression
> --------------------------------------------------------------
>
> 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)