Executing query with Hive, Tez and offset

978 Views Asked by At

I am trying to execute offset query in hive where I am trying to exclude particular records, but always getting the error below:

Query:

select * from sample order by id limit 1 OFFSET 1;  

Error:

FAILED: ParseException line 1:41 missing EOF at 'OFFSET' near '1'  

I tried dropping table and creating it again as suggested in of the SO post, but still getting the same error. Also I have already set TEZ engine in hive for faster data processing but the above query launches map reduce jobs.
Why is it so? When I execute another query it gives me direct results via TEZ engine.
Can anybody explain me this weird behaviour and as well as in solving my problem?

Environment:

1) Cloudera 5.12  
2) Hive 1.1.0-cdh5.12.0  
2

There are 2 best solutions below

3
On

Not clear why you tagged MySQL, but OFFSET does not exist as part of HiveQL SELECT syntax.

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Select

1
On

You can include the OFFSET clause with the LIMIT clause to produce paged result sets, like 11-20. Always use this clause in combination with ORDER BY (so that it is clear which item should be first, second, and so on) and LIMIT (so that the result set covers a bounded range, such as items 0-9, 100-199, and so on).