Modifed from https://github.com/petrabarus/HiveUDFs
This project uses Maven, compile it with:
mvn package
GeoIP2 uses MaxMinds GeoIP2 Database to retrieve informations from an IP Address. Any V2 database can be used, paid or lite.
Usage:
ADD JAR hive-udf.jar;
ADD FILE GeoIP2-Country.mmdb;
CREATE TEMPORARY FUNCTION geoip as 'com.spuul.hive.GeoIP2';
SELECT geoip('8.8.8.8','COUNTRY_NAME','./GeoIP2-Country.mmdb');
####FUNC(String ip, String dataType, String databasePath)
Allows you to retrive a specific information from the database. The wanted information needs to be available in the used database. You can't retrieve an city information from a country database.
- COUNTRY_CODE : Country, City
- COUNTRY_NAME : Country, City
- SUBDIVISION_NAME : City
- SUBDIVISION_CODE : City
- CITY : City
- POSTAL_CODE : City
- LONGITUDE : City
- LATITUDE : City
- ASN : ISP
- ASN_ORG : ISP
- ISP : ISP
- ORG: ISP
- IS_ANONYMOUS : Anonymous IP
- IS_ANONYMOUS_VPN : Anonymous IP
- IS_ISP : Anonymous IP
- IS_PUBLIC_PROXY : Anonymous IP
- IS_TOR_EXIT_NODE : Anonymous IP
- DOMAIN : Domain Name
- CONNECTION : Connection Type