I think I figured out. I can get map keys as an array then use concat_ws(string 
SEP, array<string>) to convert the array to a string, then I can use 
instr(string str, string substr) to test if a substring exists or not.

From: Szehon Ho [mailto:sze...@cloudera.com]
Sent: Tuesday, March 18, 2014 2:08 AM
To: user@hive.apache.org
Subject: Re: read a Hive Map without knowing keys

You can try to check other string udf's for that case, here 
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF , they will 
be in the section on string functions.

Thanks
Szehon

On Mon, Mar 17, 2014 at 5:06 PM, Frank Luo 
<j...@merkleinc.com<mailto:j...@merkleinc.com>> wrote:
That is helpful, Thx!

More dumb questions. What is "select *?" ?

Also, any hints on how to find whether the map_keys contains a substring? For 
example, supposing the map_keys contains emails, I want to see if one of the 
emails contains "gmail.com<http://gmail.com>".

From: Szehon Ho [mailto:sze...@cloudera.com<mailto:sze...@cloudera.com>]
Sent: Monday, March 17, 2014 5:14 PM
To: user@hive.apache.org<mailto:user@hive.apache.org>
Subject: Re: read a Hive Map without knowing keys

Select *?  There are other built-in functions like map_keys and map_values you 
can use in queries on maps.  Not sure if this addresses the question.

Thanks
Szehon

On Mon, Mar 17, 2014 at 3:05 PM, Frank Luo 
<j...@merkleinc.com<mailto:j...@merkleinc.com>> wrote:
Is there a way to read Hive Map datatype without knowing keys?

According to Hive document, the only way to read a Map is to access through 
keys, ie:   myMap['myKey']. However, in many cases, the keys are unknown, for 
example, HTable sparse columns, so in that kind of situation, what is the ways 
to read the map?


Reply via email to