好文档 - 专业文书写作范文服务资料分享网站

hive自定义函数说明

天下 分享 时间: 加入收藏 我要投稿 点赞

Hive自定义函数说明

函数清单:

函数名称 getID oracle_concat getBirthDay getGoodsInfo self_date_format oracle_months_between oracle_decode dateformat hive_date_format oracle_nvl/oracle_nvl2 BinomialTest days_between_360 getbirthday f_get_interest_effect f_get_monthpay_bsm f_get_monthpay_int f_get_work_days f_paymentschedule udf_dictionary 说明 _FUNC_();通过UUID生成唯一ID _FUNC_(v1,v2…,vn); 与oracle功能一致的字符串连接函数 _FUNC_(ID); 通过身份证获取生日 _FUNC_(ProductCategoryName,Manufacturer,BrandType,GoodsType); 通过配置规则,规范化商品名称 _FUNC_(date1); 格式化包含'/'的时间格式,输出格式yyyy-MM-dd HH:mm:ss _FUNC_(date1, date2); 解决当前版本的hive没有months_between函数 _FUNC_(value, search_1, result_1,...search_{n}, result_{n}[,default]); 在hive中实现oracle的decode函数,区别于hive自带的decode函数 dateformat(date/timestamp/string, fmt) converts a date/timestamp/string to a value of string in the format specified by the date format fmt default.hive_date_format('20121212','yyyyMMdd'); (return: 2012-12-12) 按照给定格式化字符串格式化时间日期 符合oracle规则的nvl/nvl2 _FUNC_(expr1, expr2, p_value, alternativeHypothesis); 实现oracle的二项分布检测函数 _FUNC_(date1, date2,num); 实现excel中的day360函数功能 _FUNC_(id string)从身份证号中提取生日 _FUNC_(分期, 本金 ,eir, 提前还款期)根据分期、本金、EIR、提前还款期(为0则为正常还款)计算的利息收入,EIR为XX% _FUNC_(id int,bir double,business_sum double,periods int)预算合同每月应还利息 _FUNC_(seqid int,bir double,business_sum double,periods int)预算合同每月应还本金 _FUNC_(入职 date1,离职 date2);根据入职 离职日期计算上月工作日期比例,不计节假日 _FUNC_ (SRC.PAYDATE,SRC.BIR/1200,SRC.PERIODS,SRC.BUSINESSSUM) 一对多函数,用于生成还款计划 _FUNC_(partition const,key1 const,key2 string) 字典表解码函数,用于从指定字典表中获取结果 default.ExtractCoordinates 中国区域内经纬度提取函数,返回包含经纬度的struct default.distanceSimplify default.f_unpivot default.f_unpivot2 两个经纬度之间的距离,采用简便求法。距离越大误差越大 行转列函数。 行转列函数。

用法:

getID

通过UUID来生成每一行的唯一ID: select getid() ;

oracle_concat

hive的concat函数遇到空值的情况下会直接返回空,而在oracle中对于字符串类型空字符串与null是等价对待的

select default.oracle_concat('ff-',null,'','--cc');

Select concat('ff-',null,'','--cc');

getBirthDay

从身份证号码中截取生日信息,返回日期格式为’yyyy-MM-dd’

getGoodsInfo

self_date_format

为格式化来自oracle的时间格式,将格式为’yyyy/MM/dd’和’yyyy/MM/dd HH:mm:ss’的日期格式转换为’yyyy-MM-dd’

Select default. self_date_format(‘2012-12-12’);

Select default. self_date_format(‘20121212’,’yyyyMMdd’);

oracle_months_between

由于当前版本hive不带months_between函数,所以添加

oracle_decode

hive中的decode函数为字符编码函数和encode对应。Oracle中decode函数类似case when函数,添加oracle_decode函数减少sql的改写。与为与oracle功能同步,本函数将null和字符串’’等价对待。

select default.oracle_decode('',null,1,2) r1, default.oracle_decode(null,'',1,2) r2,

default.oracle_decode('aaa','','Nnull','aaa','is a*3','aaa') r3, default.oracle_decode('ccc','', 'Nnull','aaa','is a*3','aaa') r4, default.oracle_decode('','', 'Nnull','aaa','is a*3','aaa') r5;

BinomialTest

_FUNC_(expr1, expr2, p_value, alternativeHypothesis) alternativeHypothesis:

接受指定值的字符串

取值:TWO_SIDED , GREATER_THAN , LESS_THAN

二项分布检测函数。实现oracle中的二项分布检测功能。

计算expr1 等于 exper2 的值占数据总数的二项分布检测结果,类型依据alternativeHypothesis确定

hive自定义函数说明

Hive自定义函数说明函数清单:函数名称getIDoracle_concatgetBirthDaygetGoodsInfoself_date_formatoracle_months_betweenoracle_decodedateformathive_date_formatoracle_nvl/oracle_nvl2Bi
推荐度:
点击下载文档文档为doc格式
07xgh3mmu46cyp27lz4y3h0qq02ukg01bx9
领取福利

微信扫码领取福利

微信扫码分享