Reputation: 1328
Consider I have 100 rows in hive table, How to fetch 30 rows which are in between 50 to 80? I remember there are few commands/queries in other languages, are there any commands/queries in Hive.
Thanks.
Upvotes: 0
Views: 161
Reputation: 9067
SELECT *
FROM
(SELECT id, aaa, bbb, ccc,
ROW_NUMBER() OVER (ORDER BY id) rank__
FROM mydb.mytable
) windowed__
WHERE rank__ BETWEEN 51 AND 80
ORDER BY rank__
That will do the trick, provided you have an "id" in your table (i.e. some unique key, or unique combination of keys).
But if you run that several times just to page your results, performance will be terrible -- that means a full MapReduce job every time.
Upvotes: 1