Tuesday, 16 September 2014

Create Hive Table Containing Array Type

Sometimes, we want to group some columns in one array of Hive table.

For example in catergory.txt
www.google.com 20140802 Entertainment,  Entertainment - Multimedia


CREATE TABLE catergory(url string, date_time int, category_array Array<string>)

ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -- This is how each field is seperated
COLLECTION ITEMS TERMINATED BY ','  -- this is how values in the struct, map and array are separated
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION '/user/cloudera/catergory'


Reference:
http://netezzaadmin.wordpress.com/2013/09/25/hives-collection-data-types/

No comments:

Post a Comment