#!/bin/bash shell文件中的头
#target_table:tag_model.mid_ope_indicators_per_day_xxt
#source_table: chiq.standard_actions_ch_app;
format_date()
{
Y=`expr substr $1 1 4`
M=`expr substr $1 6 2`
D=`expr substr $1 9 2`
echo $Y"-"$M"-"$D
}
if [ $# -eq 1 ]
then
n_date=$1
else
n_date=`date -d yesterday +"%Y-%m-%d"`
fi
v_date=$(format_date $n_date) #昨天
p_date=`date -d "$v_date -161 day " +%Y-%m-%d` #161天前
for i in $(seq 1 10)
do
hive<<start
use tag_model;
DROP TABLE IF EXISTS tag_model.dim_ope_details_qjtj_single_user_popup;
CREATE TABLE IF NOT EXISTS tag_model.dim_ope_details_qjtj_single_user_popup(ip string, mac string, p_log_date string, rid string, tv_time_popup string);
INSERT OVERWRITE TABLE tag_model.dim_ope_details_qjtj_single_user_popup
SELECT DISTINCT ip, mac, p_log_date, reportinfo['rid'] AS rid, time AS tv_time_popup
FROM chiq.standard_actions_ch_app
WHERE reporttype = 'action' AND sort = 'CH_APP' AND subclass = 'ChGlobalSearch' AND reportinfo['action'] = 'EnterApp'
AND p_log_date = date_add('$p_date', $i)
AND mac REGEXP '([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}' AND mac <> '00:00:00:00:00:00';
CREATE TABLE IF NOT EXISTS tag_model.mid_ope_indicators_per_day_test(scene string, T int, indicators map<string,string>)
COMMENT 'stardard indicators for measuring performance of recommend system' PARTITIONED BY (p_log_date string) ROW FORMAT DELIMITED FIELDS TERMINATED