[
https://issues.apache.org/jira/browse/HIVE-8089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14138102#comment-14138102
]
Sergey Shelukhin commented on HIVE-8089:
----------------------------------------
Seems to be caused by addition of a stage.
{noformat}
select key, value
from (select key, value
from src order by value limit 5)t1;
select key, value
from (select key, value
from src order by value limit 5)t1 limit 5;
{noformat}
doesn't exhibit the issue and two queries have very similar plan; wrapping both
with
{noformat}
select * from (...)t1
{noformat}
causes the 2nd query to add another stage with tablescan and limit, and causes
the results to differ.
> 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)