Warm tip: This article is reproduced from stackoverflow.com, please click
amazon-redshift python sql h3

installing h3 python library on AWS Redshift for usage in an UDF

发布于 2020-03-31 22:53:02

I was trying to install the python library from ubers H3 as a custom library for aws redshift by using this for the installation. I followed the process and created the following function:

create or replace function geo_to_h3 (lat float, lon float, h3_resolution int)
 returns varchar(60)
stable
as $$
   from h3 import h3
   return h3.geo_to_h3( lat , lon, h3_resolution)
$$ language plpythonu;

When executing it with:

select geo_to_h3(38.774467 , -9.115598, 9)

I receive the following error:

OSError: /rdsdbdata/user_lib/0/0/1334190.zip/h3/out/libh3.so.1: cannot open shared object file: Not a directory

Tried the same with installing h3cy on redshift and using it in the code but I get:

ImportError: No module named _h3

I also tested this with a simple library to validate the creation, and it works.Could be because h3 for python is just a binding to the core library in C. Any advice on how to get this running or is it not possible to install every type of python library on AWS Redshift?

Questioner
flowoo
Viewed
44
Joe Harris 2020-02-04 21:41

Libraries imported into Redshift are currently required to be pure Python. Pre-compiled C/C++ extensions are not allowed.