and*_*apo 4 python amazon-redshift udf
我已经成功创建了一个Python UDF,它接受表中的varchar值,并根据正则表达式提取该值的子字符串.
DDL中varchar列的最大大小设置为20000字节,在某些情况下,当我尝试调用它时UDF输出错误:
ERROR: Value too long for character type
Detail:
-----------------------------------------------
error: Value too long for character type
code: 8001
context: Value too long for type character varying(256)
query: 1127608
location: funcs_string.hpp:390
process: query0_73 [pid=25345]
-----------------------------------------------
Run Code Online (Sandbox Code Playgroud)
是否UDF输入变量的max varchar限制设置为256字节?如果是的话,这是我可以在我的代码中更改的内容吗?
谢谢,
and*_*apo 14
事实证明你必须在函数参数中指定长度,如果它超过256,这是默认值.所以我使用类似于:
CREATE OR REPLACE FUNCTION f_xxxxxx(val VARCHAR(20000)) RETURNS VARCHAR(20000)
IMMUTABLE AS $$
<python function here>
$$ LANGUAGE plpythonu;
Run Code Online (Sandbox Code Playgroud)