[英]Error while creating python UDF in Redshift
I am trying to create Python UDF in Amazon Redshift, and I have successfully created the UDF with no error. 我正在尝试在Amazon Redshift中创建Python UDF,并且已经成功创建了UDF,并且没有错误。 I have also created the required library for this UDF successfully.
我还成功地为此UDF创建了所需的库。 But when I execute the UDF, I get the error:
但是当我执行UDF时,出现错误:
No Module Named pyffx.
没有名为pyffx的模块。 Please look at svl_udf_log for more information
请查看svl_udf_log以获取更多信息
I have downloaded the library from pypi.org
and uploaded it to Amazon S3. 我已从
pypi.org
下载该库并将其上传到Amazon S3。 This is the link I used to download the library: 这是我用来下载库的链接:
https://pypi.org/project/pyffx/#files https://pypi.org/project/pyffx/#files
create library pyffx
language plpythonu
from 's3://aws-bucket/tmp/python_module/pyffx-0.3.0.zip'
credentials
'aws_iam_role=iam role'
region 'us-east-1';
CREATE OR REPLACE FUNCTION schema.ffx(src VARCHAR)
RETURNS VARCHAR
STABLE
AS $$
import pyffx
src = unicode(src)
value=(src)
l=len(value)
e = pyffx.String(b'secret-key', alphabet='abcedefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', length=l)
return e.encrypt(value)
$$ LANGUAGE plpythonu;
I managed to get it to work... sort of. 我设法使其正常工作。
I did the following: 我做了以下事情:
.tar.gz
file and created a .zip
of the files .tar.gz
文件并创建文件的.zip
.zip
file to Amazon S3 .zip
文件复制到Amazon S3 CREATE LIBRARY
command CREATE LIBRARY
命令加载库 However, when I use the function, I receive the error: 但是,当我使用该函数时,会收到错误消息:
Invalid operation: AttributeError: 'module' object has no attribute 'add_metaclass'
无效的操作:AttributeError: '模块'对象没有属性'add_metaclass'
My research suggests that the six
library (that provides Python 2 and 3 compatibility) is the source of this problem. 我的研究表明,这
six
库(提供Python 2和3兼容性)是此问题的根源。 The Python Language Support for UDFs - Amazon Redshift page indicates that six 1.3
is included in Redshift, yet Pip six.add_metaclass error says that this version does not include add_metaclass
. UDF的Python语言支持-Amazon Redshift页面指示Redshift中包含
six 1.3
,但Pip six.add_metaclass错误表明此版本不包括add_metaclass
。 The current version of six
is 1.12. 当前的
six
版本是1.12。
I tried to include an updated six
library in the code but wasn't successful. 我试图在代码中包括一个更新的
six
库,但没有成功。 You might be able to wrangle better than me. 您也许比我更能挣扎。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.