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

Sergey Shelukhin edited comment on HIVE-8089 at 9/17/14 9:23 PM:
-----------------------------------------------------------------

it seems that ordering in the subquery should have no effect on any outer 
limits, and outer limits cannot have effect on nested query.
So if I have numbers 1..10, and so select N from (select N order by N limit 5), 
that should return 1..5.
If we have select N from (select N order by N) limit 5 we can return any 5 
numbers in any order, because it's just like select N from table limit 5 - no 
order is guaranteed...
I will take a look if this is easy to make this behavior more "user-friendly"


was (Author: sershe):
it seems that ordering in the subquery should have no effect on any outer 
limits, and outer limits cannot have effect on nested query.
So if I sort numbers 1..10, and so select N from (select N order by N limit 5), 
that should return 1..5.
If we have select N from (select N order by N) limit 5 we can return any 5 
numbers in any order, because it's just like select N from table limit 5 - no 
order is guaranteed...
I will take a look if this is easy to make this behavior more "user-friendly"

> Ordering is lost when limit is put in outer query
> -------------------------------------------------
>
>                 Key: HIVE-8089
>                 URL: https://issues.apache.org/jira/browse/HIVE-8089
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Laljo John Pullokkaran
>            Assignee: Sergey Shelukhin
>
> It seems like hive supports order by, limit in sub queries (compiler doesn't 
> complain). However ordering seems to be lost based on where you place the 
> limit.   I haven't debugged the issue.
> ex:
> select key, c_int from (select key, c_int from (select key, c_int from t1 
> order by c_int limit 5)t1)t1;
> null  NULL
> null  NULL
> 1     1
> 1     1
> 1     1
> select key, c_int from (select key, c_int from (select key, c_int from t1 
> order by c_int)t1 limit 5)t1;
> 1     1
> 1     1
> 1     1
> null  NULL
> null  NULL
> select key, c_int from (select key, c_int from (select key, c_int from t1 
> order by c_int limit 5)t1 limit 5)t1;
> 1     1
> 1     1
> 1     1
> null  NULL
> null  NULL



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

Reply via email to