[
https://issues.apache.org/jira/browse/PHOENIX-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14375135#comment-14375135
]
James Taylor commented on PHOENIX-1749:
---------------------------------------
This would be particularly good to support in conjunction with UNION ALL, as it
provides a way to specify the order by across all statements being unioned. I
don't think we need it for GROUP BY (and that would be more difficult without
providing a lot of benefit). We could push the ORDER BY info into each separate
statement and then do a final merge sort on the client when the ResultIterators
are combined.
Supporting this would require two changes:
1. In QueryCompiler.compileSingleFlatQuery(), compute the RowProjector before
compiling the OrderBy.
2. Pass in the RowProjector to OrderByCompiler and interpret a constant number
in the order by expressions as in index into the RowProjector expressions.
[~ayingshu], [~maryannxue]
> ORDER BY and GROUP 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
>
> In postgreSQL (and many others DBs) you can specify not only column name for
> the ORDER BY and GROUP 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
> and same for GROUP_BY
> 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)