Hive does not implement pagination as limit start,end like MySQL, so it needs to be implemented in a different way.
Here are two ways I think of it: one, with a unique identification field
If a paginated table has a uniquely identified field, you can implement pagination by using this field: Get the first page of data:
Note: It is also necessary to record that the largest ID in these 10 bars is preid, as a condition for the next page.
SELECT * FROM table ORDER by ID ASC limit 10; Get second page data:
Note: Save the largest ID replacement Preid in the data at the same time.
SELECT * FROM table where ID >preid ORDER by ID ASC limit 10;
Subsequent pages get the same. Second, using the Row_number () function
If the paginated table does not have a uniquely identified field, you can implement pagination by using the row number () function. Use the Row_number () function to make this table an incremented unique identifier:
SELECT * FROM (select Row_number () over (order by XX) as Rnum, table.* from table) t where Rnum Betwneen 1 to 10;
Reference: Hive method of implementing pagination