hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bejoy KS" <>
Subject Re: Exploding Array of String in Hive
Date Sat, 11 Aug 2012 08:53:09 GMT
Hi Raihan

To fetch an element of an Array you can just specify the position of the element in your query.

Say if you have a table like
'test_table' with a field 'arr_clmn Array<STRING>', you can get the first element of
the array as

SELECT arr_clmn[0] FROM test_table;

Or if you are looking at exploding the row itself to multiple rows you can do so with

SELECT * FROM test_table LATERAL VIEW explode(arr_clmn) exp_arr AS arr_elmnt;


Bejoy KS

Sent from handheld, please excuse typos.

-----Original Message-----
From: Techy Teck <>
Date: Fri, 10 Aug 2012 20:22:26 
To: <>
Subject: Re: Exploding Array of String in Hive

Basically How can I get each String outside, something like
*favorite_result [3]
should return *"VAN%2C%20Under%20£1%2C000%2E00%20Ending%20within%202%20days",

On Fri, Aug 10, 2012 at 8:04 PM, Techy Teck <> wrote:

> Below is the data in *favorite_result (datatype: array<string>) *column.
> Its an array of String in hive-
> ["CARS%20500%2E00","cars","VAN%2C%20Under%20£1%2C000%2E00%20Ending%20within%202%20days","COM%20VE","SNAP%20ON%20-LENS%20-BATTERY%20-BELT%20-PHONE%20-IPHONE","Under%20£100%2E00","","","",""]
> How I can explode this above string in hive?

View raw message