Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

project array to columns in hive

Tags:

hive

Is it possible to project an array into separate columns in hive in one step?

I have this query

select split(activity_data,":") as ad from log_table 

where the column ad contains 10 separate fields which I would like to project into 10 columns.

like image 681
jamborta Avatar asked Mar 24 '23 11:03

jamborta


1 Answers

Yes it is possible. I know there are two ways to do this:

  1. Use indices to access array elements:

    select split(activity_data,":")[0] as col1, split(activity_data,":")[1] as col2 ... from mpod_audit_log

  2. explained on this post. Explode the Array of Struct in Hive

like image 168
dino.keco Avatar answered Apr 02 '23 03:04

dino.keco