Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 09-26-2016 01:45 PM
How to get the row number for particular values from hive table: For example i have column name with VAX_NUM and one of the values for this column is 0006756423. I want know the row number for this value. Do the needful. Thanks
Created 09-26-2016 03:51 PM
I guess you can use something like
SELECT vax_num, rowid FROM (SELECT vax_num, ROW_NUMBER() OVER() AS rowid FROM <table_name>) <temporary_table_name> WHERE vax_num=0006756423
To give an example for the above:
SELECT id, rowid FROM (SELECT id, row_number() over() AS rowid FROM id_table) id_table_temp WHERE id=17; INFO : Session is already open INFO : Dag name: select id, rowid FROM (select id,...id=17(Stage-1) INFO : INFO : Status: Running (Executing on YARN cluster with App id application_1474453714086_0008) INFO : Map 1: 0/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0(+1)/1 INFO : Map 1: 1/1 Reducer 2: 1/1 +------+--------+--+ | id | rowid | +------+--------+--+ | 17 | 5 | +------+--------+--+ 1 row selected (12.202 seconds)
Please refer to: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics and Apache Hive Cookbook
Created 09-26-2016 03:51 PM
I guess you can use something like
SELECT vax_num, rowid FROM (SELECT vax_num, ROW_NUMBER() OVER() AS rowid FROM <table_name>) <temporary_table_name> WHERE vax_num=0006756423
To give an example for the above:
SELECT id, rowid FROM (SELECT id, row_number() over() AS rowid FROM id_table) id_table_temp WHERE id=17; INFO : Session is already open INFO : Dag name: select id, rowid FROM (select id,...id=17(Stage-1) INFO : INFO : Status: Running (Executing on YARN cluster with App id application_1474453714086_0008) INFO : Map 1: 0/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0(+1)/1 INFO : Map 1: 1/1 Reducer 2: 1/1 +------+--------+--+ | id | rowid | +------+--------+--+ | 17 | 5 | +------+--------+--+ 1 row selected (12.202 seconds)
Please refer to: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics and Apache Hive Cookbook
Created 10-03-2016 06:18 AM
Is this issue resolved?
Created 10-03-2016 10:10 AM
Yess.. Thanks Ayub
Created 10-03-2016 10:40 AM
@Sundar Lakshmanan If "Yess", can you please accept Ayub's answer to help us manage answered questions. Tnx!