ABC项目Hive开发规范目录ABC项目...........................................................................................................................................1Hive开发规范..................................................................................................................................11.ABC架构图.......................................................................................................................22.Oracle包或过程转换成Hive脚本图..............................................................................23.项目文件夹命名规范.......................................................................................................34.shell脚本文件命名规范..................................................................................................45.sql脚本文件命名规范.....................................................................................................46.临时表命名规范...............................................................................................................47.基表命名规范...................................................................................................................48.结果表命名规范...............................................................................................................69.配置表命名规范...............................................................................................................710.维度表命名规范...............................................................................................................711.日志记录格式...................................................................................................................812.注释...................................................................................................................................913.Partition列........................................................................................................................914.字符集...............................................................................................................................915.Shell脚本编写规范..........................................................................................................916.SQL程序体编写规范......................................................................................................1117.Sqoop数据同步.............................................................................................................1318.Sqoop手功同步脚本.....................................................................................................1619.Hive程序优化................................................................................................................1620.常用工具代码.................................................................................................................171.ABC架构图Hadoop关务系统输单系统FVP系统ODSLSCM仓配ABC维度表ABC_RR手功动因ABC资源表/ods/系统编号/result/ods/fin_abc/fin_abc//result/fin_abc/fin_abc/hiveEbill结算系统OMS仓配系统会员系统ABC_Ora2.Oracle包或过程转换成Hive脚本图p_模块名称_Param_job.sh(Shell脚本文件)Oracle建表脚本.sql(程序名称.sql)P_程序名1_Body.sql(程序1)Oracle包程序(PKG_程序名称)将Oracle包程序转成shell脚本与Hive的sql脚本调用hive的sql脚本Hive建表脚本.sh(程序名称_Tab.sh)将Orcle的表结构转换成Hive的表结构p_程序名称_Param_job.sh(Shell脚本文件)P_程序名_Body.sql(程序)Oracle过程程序(PROC_程序名称)将Oracle脚本转换成shell脚本与Hive的sql脚本调用hive的sql脚本P_程序名2_Body.sql(程序2)P_程序名3_Body.sql(程序3)调用hive的sql脚本调用hive的sql脚本具体案例:A、Oracle建表脚本.sqlHive建表脚本.shHive程序脚本1.sqlB、Oracle程序包.sqlshell调度脚本.shHive程序脚本2.sqlC、Oracle存储过程.sqlshell调度脚本.shHive程序脚本.sql3.项目文件夹命名规范项目文件夹命名规范项目英文名称缩写如ABC作业成本项目:abc_cost程序文件夹命名规范p_项目名称_模型名称_Param_Job如ABC作业成本项目:p_abc_waybill_model_Param_Job4.shell脚本文件命名规范shell建表脚本文件命名规范p_项目名称_模型名称_Tab.sh如ABC作业成本项目:p_abc_waybill_model_Tab.shshell调度脚本命名规范一级调度脚本:p_项目名称_程序名称_Param_Job.sh(只调sql脚本)二级调度脚本:p_项目名称_程序名称_Param_Job_run.sh(只调一级shell脚本)总调度脚本:p_项目名称_模型名称_Param_Job_Total_run.sh(只调二级shell脚本)如ABC作业成本项目:一级调度脚本:p_abc_waybill_input_Param_Job.sh二级调度脚本:p_abc_waybill_input_Param_Job_run.sh总调度脚本:p_abc_waybill_model_Param_Job_Total_run.sh5.sql脚本文件命名规范Sql程序体脚本文件命名p_项目名称_模型名称_程序名称_Body.sql如ABC作业成本项目:p_abc_waybill_model_input_Body.sql6.临时表命名规范项目名称_模型名称_程序名称_TMP如ABC作业成本项目:abc_waybill_model_input_tmp01注意:在hive中临时表建成内部表,需要时创建不需要时删除。数据类型如下:时间:STRING整形:INT,BIGINT字符串:STRING浮点:DOUBLE7.基表命名规范项目名称_BSL_模块名称_程序名称如ABC作业成本项目:abc_bsl_waybill_model_input基表数据存放路径:/result/系统编码/数据库/bsl/表名如ABC作业成本项目:/result/fin_abc/fin_abc/bsl/abc_bsl_waybill_model_input案例如下:droptableifexistsabc_bsl_waybill_model_input;createexternaltableabc_bsl_waybill_model_input(month_codestringcomment'月份',waybill_nostringcomment'运单号',waybill_type_codestringcomment'清回单标识',tickets_01doublecomment'公共信息票数(票数*系数)',untickets_01bigintcomment'公共信息票数',ctickets_01doublecomment'公共信息系数',tickets_02doublecomment'寄件方信息票数(票数*系数)',untickets_02bigintcomment'寄件方信息票数',ctickets_02doublecomment'寄件方信息系数',tickets_ratedoublecomment'系数',inner_flgstringcomment'自营外包输单标识',bill_pd_codestringcomment'产品代码',input_dept_codestringcomment'输单网点(自营到录入员工网点,外包则是运单的清单寄件区,回单目的区)',abc_dept_typestringcomment'abc网点类型',abc_input_dept_codestringcomment'abc输单网点',abc_area_type_codestringcomment'abc区域',tipsbigintcomment'碎