我如何使用类似 oracle 函数的 plpythonu 在 AWS Redshift UDF 中执行选择查询,并在函数中选择进入类,如下所示。
CREATE OR REPLACE FUNCTION udf(id varchar(50))
RETURNS VARCHAR(50)
STABLE
AS $$
result = plpy.execute("SELECT count(*) FROM abc")
return result
$$ LANGUAGE plpythonu;
当我运行上述函数时出现以下错误。
ERROR: XX000: NameError: global name 'plpy' is not defined. Please look at svl_udf_log for more information
请您参考如下方法:
它在 Postgresql ( https://www.postgresql.org/docs/9.2/static/plpython-database.html ) 上可用。
目前不支持 Amazon Redshift。
与您在这个网址上的问题相同: https://blogs.aws.amazon.com/bigdata/post/Tx1IHV1G67CY53T/Introduction-to-Python-UDFs-in-Amazon-Redshift
