./examples # 阿里云官方提供测试样例
./manual_compile_jar # 手动编译后的jar,去除掉沙箱限制的类调用
./sqlscripts/create_table # 创建表结构SQL
./sqlscripts/extract_features # 提取特征SQL
./sqlscripts/json_data_flat # JSON数据扁平化SQL
./sqlscripts/scripts #
./sqlscripts/sync_sql # 同步数据SQL
./src # 程序源码
./target # 程序编译结果
./warehouse # 阿里云官方提供测试样例
MaxCompute MapReduce及UDF程序在分布式环境中运行时受到Java沙箱的限制
参考地址: https://help.aliyun.com/document_detail/50902.html?spm=5176.doc50898.6.743.aeu8xc
-
从git拉取项目至本地。如E:\mc_luna。
-
使用安装好MaxCompute插件的Intellij IDEA打开,确保已配置好可用的MaxCompute项目,例如RMDC_DW。
-
定义继承UDF父类的子类,实现函数。例如:src/main/java/myudf/GetCountByDate
-
在项目中右键或者使用快捷键ctrl+alt+F10运行。初次运行会弹出配置对话框。需要依次填入:
- MaxCompute Project
- maxcompute table
- table partition
- table columns
其中table columns的个数与类型应该符合定义的函数参数列表。
-
配置完毕后运行即可。
- 与UDF类似。
gradle install com.jayway.JsonPath lib
mvn clean package mc_luna.jar
add jar d:/mc_luna.jar -f
// 添加文件
add file <local_file> [as alias] [comment 'cmt'][-f];
CREATE FUNCTION test_udtf AS 'myudf.UDTFHello' USING 'mc_luna.jar';
CREATE FUNCTION test_udf AS 'myudf.UDFPlusHello' USING 'mc_luna.jar';
// 测试udtf
select mytest_udtf(bank_name,bank_name) from odps_ebank_detail limit 1;
// 测试udf
select test_udf(person_id,account_info) from odps_ebank_detail limit 1;
// 上传文件
tunnel upload d:/period.txt period_feature -fd '\t';
- 因为Maxcompute开发的udf或mr时在maxcompute上运行存在沙箱限制,不允许特定包进行调用。
所以在开发过程中,如果使用了第三方Jar包来完成部分功能时,需要手动将调用限制那块的代码去除掉,然后重新打成jar包。
目前我们使用
/manual_compile_jar
目录为存放重新编译的jar包,如果你使用maven打包程序需要该包替换到maven目录下自动下载的包。
函数 | 说明 |
---|---|
id_card_province(string) -> string | 由身份证号获取省份 |
id_card_city(string) -> string | 由身份证号获取城市 |
id_card_area(string) -> string | 由身份证号获取区或县 |
id_card_birthday(string) -> string | 由身份证号获取出生日期 |
id_card_gender(string) -> string | 由身份证号获取性别 |
is_valid_id_card(string) -> boolean | 鉴别是否是有效的身份证号 |