Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive, mail # user - get_json_object cannot handle array


Copy link to this message
-
get_json_object cannot handle array
Steven Wong 2010-08-18, 22:07
I have a string column that contains a JSON array on each row. Calling the function get_json_object on that column always returns NULL:

$ hive -e "select cdnbwdata, get_json_object(cdnbwdata, '$'), get_json_object(cdnbwdata, '$[0].rtt'), get_json_object(cdnbwdata, '$.rtt') from mytable"
[{"id":9,"ip":"173.223.232.50","rtt":71,"bw":41943}] NULL NULL NULL

If I replace the array with its 0th element, then get_json_object works:

$ hive -e "select cdnbwdata, get_json_object(cdnbwdata, '$'), get_json_object(cdnbwdata, '$[0].rtt'), get_json_object(cdnbwdata, '$.rtt') from mytable"
{"id":9,"ip":"173.223.232.32","rtt":71,"bw":4211}     {"id":9,"bw":4211,"rtt":71,"ip":"173.223.232.32"}    NULL 71

Is it a get_json_object bug in handling arrays, or am I doing something wrong? Hive version is 0.5.

Thanks.
Steven