Skip to content
Advertisement

GeoIP2 Snowflake Java UDF Integration issue

I want to create a Java UDF in a snowflake worksheet in order to query GeoIp2 library and get the ISO code of a given IP. I have ‘@AWS_CSV_STAGE/lib/geoip2-2.8.0.jar’,’@AWS_CSV_STAGE/geodata/GeoLite2-City.mmdb’ already staged. How can i direct the function handler to the method that creates the Database Reader as explained here in the documentation for Java: https://dev.maxmind.com/geoip/geolocate-an-ip/databases?lang=en#1-install-the-geoip2-client-library in general how can i achieve this whole thing below in my udf?

JavaScript

so far i wrote this but of course it’s not working: anyway i couldn’t find much material about how to tackle this kind of problem.

JavaScript

basically what i want to achieve is to call the UDF on a column of ip address table and get the country code in another column for each ip address.

Advertisement

Answer

Thanks for this question – I wrote a whole post going step-by-step to get this working:

You had the right idea in the code you posted, a full working UDF would be:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement