0
votes

I'm looking for a HIVE UDF that will parse an array of data into a tabular form. If there's nothing in HIVE, a PIG example would be appreciated.

The input is in this format:

date timestamp key1="val1" key2="val2" key3="val3" year month day

date timestamp key1="val4" key2="val5" key3="val6" year month day

Would like the results to be a table where the column names are the keywords and the results are the values. Such as:

results:

column_name key1 key2 key3

results val1 val2 val3

          val4    val5    val6
1

1 Answers

0
votes

As of my understanding about your issue,i am pointing one solution.

first create a table in hive.

 create table example1(dates string,timestamps string,key1 map<string,string>,key2 map<string,string>,key3 map<string,string>,year int, month string,day string) row format delimited fields terminated by ' ' map keys terminated by '='; 

create another table like

create table example2(key1 string,key2 string,key3 string)

insert the data into second table from first table

insert into  table example2  select key1["key1"],key2["key2"],key3["key3"]  from example1; 

output:

select * from example2;

"val1"  "val2"  "val3"
"val4"  "val5"  "val6"

in this, i am not concentrating on data types.