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.
Yes it is possible. I know there are two ways to do this:
Use indices to access array elements:
select split(activity_data,":")[0] as col1, split(activity_data,":")[1] as col2 ... from mpod_audit_log
explained on this post. Explode the Array of Struct in Hive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With