hive 自定义函数 临时函数:
ADD JAR hdfs://xxxxxxxx/user/hive/warehouse/bin/ToJsonUDF/brickhouse-0.7.1.jar;
CREATE TEMPORARY FUNCTION from_json AS 'brickhouse.udf.json.FromJsonUDF';
ADD JAR hdfs://nameservice1/user/hive/warehouse/bin/ToJsonUDF/brickhouse-0.7.1.jar;
CREATE TEMPORARY FUNCTION from_json AS 'brickhouse.udf.json.FromJsonUDF';
show functions
示例:
select t1.c1[0]
from ( select from_json('[{"key1":"1"},{"key2":"2"}]', -- map( "", array( cast(0 as int)) array(map("","") ) ) c1 ) t1
lateral view explode( from_json( get_json_object(msg,'$.total') ,array(string( "")) ) ) xxxx_view as sales
包来源网址:
https://brickhouseconfessions.wordpress.com/2014/02/07/hive-and-json-made-simple/