#!/usr/sh

DT=$(date +%Y%m%d -d "-1 day $ScheduleTime")

LAST_DT=$(date +%Y%m%d -d "-7 day $DT")

hive -hivevar dt=${DT} -hivevar last_dt=${LAST_DT} -f app_tag.sql

sqoop export --connect jdbc:mysql://dataplatform-app-tag.c5yzcdreb1xr.us-east-1.rds.amazonaws.com:3306/app_tag  \
    --username apptag_rw --password 7gyLEVtkER3u8c9 --table tag_list --columns "package_name,app_name,platform,category,url,install" \
    --export-dir s3://mob-emr-test/dataplatform/DataWareHouse/dwh.db/package_list --input-fields-terminated-by '\001' --update-mode allowinsert --update-key package_name

hive -e "USE dwh;DROP TABLE IF EXISTS package_num;"

hive -e "USE dwh;DROP TABLE IF EXISTS package_info;"

hive -e "USE dwh;DROP TABLE IF EXISTS package_list;"