Aravind Kumar Anugula
Aravind Kumar Anugula

Reputation: 1326

Hadoop Hive query to merge rows into one row

I need one hive query which merge same EAN rows into one record in table based on priority which is another table.

table: products enter image description here

As shown in the above image I have different products from different sources(sourceid) and I want only one row by merging all sources data based on below priority. If priority "1" source doesn't provide any field info, that field info will be taken from priority "2" source.

Table: priority

node_id Source_id   Priority
1        62          1
1        303         2
1        202         3

I am expecting results as shown below.

enter image description here

Upvotes: 0

Views: 1881

Answers (1)

ankush reddy
ankush reddy

Reputation: 501

you can actually use collect udf to collect all the other fields based on one field.

or you can use some nested arrays or struct to get the data into single row, If you don't want to loose any data.

Upvotes: 1

Related Questions