项目作者: hellojinjie

项目描述 :
hive udf functions, e.g. MaxMind 的 GEO 函数
高级语言: Java
项目地址: git://github.com/hellojinjie/hive-function.git
创建时间: 2013-10-29T07:50:41Z
项目社区:https://github.com/hellojinjie/hive-function

开源协议:Apache License 2.0

下载


hive-function

hive udf/udaf/udtf functions

Usage
=
Add jars

  1. add file file:///home/qos/GeoLite2-City.mmdb;
  2. add jar hdfs:/user/jj/geo/jackson-core-2.2.0.jar;
  3. add jar hdfs:/user/jj/geo/jackson-annotations-2.2.0.jar;
  4. add jar hdfs:/user/jj/geo/jackson-databind-2.2.0.jar;
  5. add jar hdfs:/user/jj/geo/maxminddb-0.3.0.jar;
  6. add jar hdfs:/user/jj/geo/geoip2-0.6.0.jar;
  7. add jar hdfs:/user/jj/hive/hive-function-1.0-SNAPSHOT.jar;

Create temporary function

  1. create temporary function shaman_geo_countrycode as 'shaman.hive.udf.UDFGeoIPCountryCode';
  2. create temporary function shaman_geo_countryname as 'shaman.hive.udf.UDFGeoIPCountryName';
  3. create temporary function shaman_geo_isp as 'shaman.hive.udf.UDFGeoIPIsp';

Example usage of geo udf

  1. create temporary function shaman_geo_countrycode as 'shaman.hive.udf.UDFGeoIPCountryCode';
  2. select shaman_geo_countrycode('54.206.1.110') from jj.dual;

Example usage of map value sum

  1. add jar ./target/hive-function-1.0-SNAPSHOT.jar;
  2. create temporary function shaman_sum_mapvalue as 'shaman.hive.udf.UDFMapValueSum';
  3. select shaman_sum_mapvalue(map('a', 344, 'b', 4444)) from jj.dual limit 1;
  4. select shaman_sum_mapvalue(map('a', 344444444444, 'b', 44444444444444)) from jj.dual limit 1;

Example usage of array value sum

  1. add jar hdfs:///user/jj/hive/hive-function-1.0-SNAPSHOT.jar;
  2. create temporary function shaman_sum_array as 'shaman.hive.udf.UDFArraySum';
  3. select shaman_sum_array(array(1,2,3,4)) from jj.dual;
  4. select shaman_sum_array(array(1,2,3,411111111111111111)) from jj.dual;