通过Shell数组传参控制Sql脚本串并行调度一例
来源:互联网 发布:javascript bind this 编辑:程序博客网 时间:2024/06/07 03:40
一、目录环境
二、串并行调度的Shell脚本
[hadoop@emr-worker-9 UserPortrait]$ cat user_portrait_view_moreThread.sh
三、执行的Sql示例
[hadoop@emr-worker-9 UserPortrait]$ pwd/home/hadoop/nisj/UserPortrait[hadoop@emr-worker-9 UserPortrait]$ lltotal 616-rw-r--r-- 1 hadoop hadoop 2516 Mar 7 18:21 indexCalc-barrage-byUidOnly.sql-rw-r--r-- 1 hadoop hadoop 4160 Mar 8 16:38 indexCalc-gift-byUidOnly.sql-rw-r--r-- 1 hadoop hadoop 4562 Mar 7 14:29 indexCalc-view-byGameId.sql-rw-r--r-- 1 hadoop hadoop 4562 Mar 7 14:29 indexCalc-view-byRoomId.sql-rw-r--r-- 1 hadoop hadoop 4529 Mar 7 14:29 indexCalc-view-byTagId.sql-rw-r--r-- 1 hadoop hadoop 4411 Mar 7 14:29 indexCalc-view-byUidOnly.sql-rw-r--r-- 1 hadoop hadoop 4292 Mar 7 14:29 indexCalc-view-historyBehavior.sql-rw------- 1 hadoop hadoop 565692 Mar 8 17:55 nohup.out-rwxr-x--- 1 hadoop hadoop 569 Mar 8 16:38 user_portrait_view_moreThread.sh
二、串并行调度的Shell脚本
[hadoop@emr-worker-9 UserPortrait]$ cat user_portrait_view_moreThread.sh
#!/usr/bin/env bashecho `date`,'数据跑批开始...'indexCalc_sqlFile_array=(indexCalc-view-byGameId.sqlindexCalc-view-byRoomId.sqlindexCalc-view-byTagId.sqlindexCalc-view-byUidOnly.sqlindexCalc-barrage-byUidOnly.sqlindexCalc-gift-byUidOnly.sql)for indexCalc_sqlFile in ${indexCalc_sqlFile_array[*]}do{/usr/lib/hive-current/bin/hive -f /home/hadoop/nisj/UserPortrait/$indexCalc_sqlFilesleep 1} &donewait/usr/lib/hive-current/bin/hive -f /home/hadoop/nisj/UserPortrait/indexCalc-view-historyBehavior.sqlsleep 1echo `date`,'数据跑批完成!'
三、执行的Sql示例
/home/hadoop/nisj/UserPortrait/indexCalc-view-byGameId.sql
-- 观看时长等的计算-- 观看总时长、总次数;有效观看总时长、有效观看次数、有效平均时长;第一次观看时间drop table if exists rcd_static_view_bygameid_basic;create table rcd_static_view_bygameid_basic aswith Tab_recommend_data_view_byDay as(select uid,gameid,sum(view_time) view_time,pt_day from recommend_data_view where uid>0 group by uid,gameid,pt_day)select uid,gameid,sum(view_time) total_view_time,count(view_time) total_view_times,sum(case when view_time>=5 then view_time else 0 end ) total_view_time_effective,sum(case when view_time>=5 then 1 else 0 end ) total_view_times_effective,sum(case when view_time>=5 then view_time else 0 end )/sum(case when view_time>=5 then 1 else 0 end ) avg_view_time_effective,min(pt_day) frist_view_day,max(pt_day) newest_view_dayfrom Tab_recommend_data_view_byDay group by uid,gameid;-- 最后一次、倒数第二次有效观看及单次有效最大观看时长相关(时长与时间)drop table if exists rcd_static_view_bygameid_rank;create table rcd_static_view_bygameid_rank aswith Tab_recommend_data_view_byDay as(select uid,gameid,sum(view_time) view_time,pt_day from recommend_data_view where uid>0 group by uid,gameid,pt_day)select uid,gameid,max(case when effective_desc_rk=1 then pt_day end) tailender_effective_day,max(case when effective_desc_rk=1 then view_time end) tailender_effective_view_time,max(case when effective_desc_rk=2 then pt_day end) penul_timate_effective_day,max(case when effective_desc_rk=2 then view_time end) penul_timate_effective_view_time,max(case when effective_desc_rk2=1 then pt_day end) max_effective_view_day,max(case when effective_desc_rk2=1 then view_time end) max_effective_view_timefrom (select uid,gameid,view_time,pt_day,row_number()over(partition by uid,gameid order by pt_day desc) effective_desc_rk,row_number()over(partition by uid,gameid order by view_time desc) effective_desc_rk2from Tab_recommend_data_view_byDaywhere view_time>=5) x1group by uid,gameid;-- 最近七天有效观看时长drop table if exists rcd_static_view_bygameid_last7day;create table rcd_static_view_bygameid_last7day aswith Tab_recommend_data_view_byDay as(select uid,gameid,sum(view_time) view_time,pt_day from recommend_data_view where uid>0 group by uid,gameid,pt_day)select uid,gameid,sum(case when view_time>=5 then view_time else 0 end ) total_view_time_effective,sum(case when view_time>=5 then 1 else 0 end ) total_view_times_effective,sum(case when view_time>=5 then view_time else 0 end )/sum(case when view_time>=5 then 1 else 0 end ) avg_view_time_effective,min(pt_day) frist_view_day,max(pt_day) newest_view_dayfrom Tab_recommend_data_view_byDay where view_time>=5 and pt_day between date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),7) and date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),1)group by uid,gameid;-- 按周统计每周有效观看时长drop table if exists rcd_static_view_bygameid_byweek;create table rcd_static_view_bygameid_byweek aswith Tab_recommend_data_view_byDay as(select uid,gameid,sum(view_time) view_time,pt_day from recommend_data_view where uid>0 group by uid,gameid,pt_day)select uid,gameid,concat(year(pt_day),'@',weekofyear(pt_day)) week_no,sum(case when view_time>=5 then view_time else 0 end ) total_view_time_effective,sum(case when view_time>=5 then 1 else 0 end ) total_view_times_effective,sum(case when view_time>=5 then view_time else 0 end )/sum(case when view_time>=5 then 1 else 0 end ) avg_view_time_effective,min(pt_day) frist_view_day,max(pt_day) newest_view_dayfrom Tab_recommend_data_view_byDay where view_time>=5group by uid,gameid,concat(year(pt_day),'@',weekofyear(pt_day));-- 按月统计每月有效观看时长drop table if exists rcd_static_view_bygameid_bymonth;create table rcd_static_view_bygameid_bymonth aswith Tab_recommend_data_view_byDay as(select uid,gameid,sum(view_time) view_time,pt_day from recommend_data_view where uid>0 group by uid,gameid,pt_day)select uid,gameid,concat(year(pt_day),'@',month(pt_day)) month_no,sum(case when view_time>=5 then view_time else 0 end ) total_view_time_effective,sum(case when view_time>=5 then 1 else 0 end ) total_view_times_effective,sum(case when view_time>=5 then view_time else 0 end )/sum(case when view_time>=5 then 1 else 0 end ) avg_view_time_effective,min(pt_day) frist_view_day,max(pt_day) newest_view_dayfrom Tab_recommend_data_view_byDay where view_time>=5group by uid,gameid,concat(year(pt_day),'@',month(pt_day));
0 0
- 通过Shell数组传参控制Sql脚本串并行调度一例
- 通过web控制Shell脚本
- Shell脚本编程-流控制(一)
- Linux shell脚本传参,传入数组
- 在Oozie 中调度执行shell、hive 脚本,以及通过shell脚本执行hive/sqoop/shell脚本的方法
- Shell脚本并行化处理
- SQL 通过shell 传参数
- Linux定时调度shell脚本
- shell脚本之注释,数组,控制语句,函数【shell脚本的学习笔记二】
- shell调度控制面命令
- shell脚本超时控制
- shell脚本超时控制
- shell脚本超时控制
- shell脚本逻辑控制
- shell 脚本并发控制
- Shell脚本控制语句
- shell脚本流程控制
- 如何通过Shell脚本显示一幅图片
- JVM调优-新一代的垃圾回收算法
- 汇编中各寄存器的作用
- MyBatis错误:元素类型为 "configuration" 的内容必须匹配
- Nginx的一些基本功能极速入门
- js点击事件多次触发问题
- 通过Shell数组传参控制Sql脚本串并行调度一例
- 微服务访问安全设计方案全探索
- Hibernate one-to-one一对一映射
- ECshop增加paypal_EC流程
- C# 修饰符
- iterm 分屏切换快捷键
- linux下的连接管理工具xshell的使用
- JVM进阶(十)——JAVA 年老代收集器
- DOM文档对象模型