您现在的位置是:首页 > 文章详情

AWS redshift->hdb pg(Greenplum), plpython, pljava UDF 以及upload library

日期:2018-10-18点击:573

背景
AWS redshift UDF 支持sql, plpython编写。

阿里云hdb pg UDF支持plpgsql, sql, plpython, pljava编写。

aws redshift通过create library导入外部LIB。

阿里云hdb pg同样通过CREATE LIBRARY导入外部LIB。

redshift 创建UDF函数
https://docs.aws.amazon.com/redshift/latest/dg/udf-creating-a-scalar-udf.html

CREATE [ OR REPLACE ] FUNCTION f_function_name
( { [py_arg_name py_arg_data_type |
sql_arg_data_type } [ , ... ] ] )
RETURNS data_type
{ VOLATILE | STABLE | IMMUTABLE }
AS

$$ { python_program | SELECT_clause } $$

LANGUAGE { plpythonu | sql }

create function f_py_greater (a float, b float)
returns float
stable
as

$$ if a > b: return a return b $$

language plpythonu;
redshift 导入python lib
CREATE [ OR REPLACE ] LIBRARY library_name LANGUAGE plpythonu
FROM
{ 'https://file_url'
| 's3://bucketname/file_name'
authorization
[ REGION [AS] 'aws_region']
}
阿里云hdb pg创建UDF函数
https://help.aliyun.com/document_detail/50594.html

create extension pljava;

create library example language java from 'oss://oss-cn-hangzhou.aliyuncs.com filepath=analytics.jar id=xxx key=yyy bucket=zzz';

create table temp (a varchar) distributed randomly;
insert into temp values ('my string');
create or replace function java_substring(varchar, int, int) returns varchar as 'Test.substring' language java;
select java_substring(a, 1, 5) from temp;
阿里云hdb pg导入java lib
https://help.aliyun.com/document_detail/50595.html

CREATE LIBRARY library_name LANGUAGE [JAVA] FROM oss_location OWNER ownername
CREATE LIBRARY library_name LANGUAGE [JAVA] VALUES file_content_hex OWNER ownername
DROP LIBRARY library_name
create library example language java from 'oss://oss-cn-hangzhou.aliyuncs.com filepath=analytics.jar id=xxx key=yyy bucket=zzz';
参考
https://help.aliyun.com/document_detail/50595.html

https://help.aliyun.com/document_detail/50594.html

https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_LIBRARY.html
转自阿里云德哥

原文链接:https://yq.aliyun.com/articles/655505
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章