You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Saurabh Nanda <sa...@gmail.com> on 2010/01/05 11:01:12 UTC

Populating MAP type columns

From
http://wiki.apache.org/hadoop/Hive/Tutorial#Map.28Associative_Arrays.29_Operationsit
seems that "Such structures can only be created programmatically
currently".

What does this mean exactly? Do I have to use the Java based APi to insert
data into such columns? If that is the case, has someone written a UDF which
lets me import weblog cookie data into a MAP column using only the Hive QL.
The cookie data is of the following format:

cookie_name1=value; cookie_name2=value; cookie_name3=value

If there is no such UDF available, would it be a good idea to include one in
the standard Hive distribution?

Thanks,
Saurabh.
-- 
http://nandz.blogspot.com
http://foodieforlife.blogspot.com

RE: Populating MAP type columns

Posted by Zheng Shao <zs...@facebook.com>.
Hi Saurabh,

I think we can do it with the following 3 UDFs.

make_map(trim(split(cookies, ",")), "=")

ArrayList<String> split(String) See http://issues.apache.org/jira/browse/HIVE-642
ArrayList<String> trim(ArrayList<String>)  Open one for that
HashMap<String,String> make_map(ArrayList<String>, String separator) Open one for that

The last 2 need to be written. Please open a JIRA for each.
It will be great if you are interested in working on that. There are some examples in the contrib directory already (search for "UDFExampleAdd"). See http://wiki.apache.org/hadoop/Hive/HowToContribute

Zheng
From: Saurabh Nanda [mailto:saurabhnanda@gmail.com]
Sent: Tuesday, January 05, 2010 2:01 AM
To: hive-user@hadoop.apache.org
Subject: Populating MAP type columns

>From http://wiki.apache.org/hadoop/Hive/Tutorial#Map.28Associative_Arrays.29_Operations it seems that "Such structures can only be created programmatically currently".

What does this mean exactly? Do I have to use the Java based APi to insert data into such columns? If that is the case, has someone written a UDF which lets me import weblog cookie data into a MAP column using only the Hive QL. The cookie data is of the following format:
cookie_name1=value; cookie_name2=value; cookie_name3=value

If there is no such UDF available, would it be a good idea to include one in the standard Hive distribution?

Thanks,
Saurabh.
--
http://nandz.blogspot.com
http://foodieforlife.blogspot.com