Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

row_number in hive query giving error : Only COMPLETE mode supported for row_number function (state=42000,code=40000)

avatar
Explorer

select row_number(),* from testDB.testTable;

Error: Error while compiling statement: FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: Only COMPLETE mode supported for row_number function (state=42000,code=40000)

1 REPLY 1

avatar
Master Guru

@PP

Include over() clause in your select query .

Try with below query:

select row_number() over(),* from testDB.testTable;

Example:

select row_number() over() as rn,* 
from (
select stack(2,1,"foo",2,"bar") as (id,name)
)t; +-----+-------+---------+--+ | rn | t.id | t.name | +-----+-------+---------+--+ | 1 | 1 | foo | | 2 | 2 | bar | +-----+-------+---------+--+

"rn" is the row number column that we have added in the above result.