Here i am trying to import a library inside my user defined python function in redshift
I have created an library called nltk as follows
[CREATE OR REPLACE LIBRARY nltk LANGUAGE plpythonu FROM 's3://nltk.zip' CREDENTIALS 'aws_access_key_id=*****;aws_secret_access_key=****';]
once created i tried to import this in a function as
CREATE OR REPLACE FUNCTION f_function (sentence varchar)
RETURNS VARCHAR STABLE AS $$
from nltk import tokenize
token = nltk.word_tokenize(sentence)
return token $$ LANGUAGE plpythonu;
tokenize is a sub directory inside nltk library
but when i try to run the function by calling it on a table as
SELECT f_function(text) from table_txt;
I am getting an error as such
Amazon Invalid operation: ImportError: No module named nltk. Please look at svl_udf_log for more information
Details:
-----------------------------------------------
error: ImportError: No module named nltk. Please look at svl_udf_log for more information
code: 10000
context: UDF
query: 69145
location: udf_client.cpp:298
process: query0_21 [pid=3165]
Can anyone help me where am i doing it wrong?