#!/bin/bash

# # # # # # # # # # # # # # # # # # # # # #
# @file    :trackingnew_merge_daily.sh
# @author  :wangjf
# @revision:2019-11-26 11:22:36
# # # # # # # # # # # # # # # # # # # # # #

source ../../dmp_env.sh

today=${ScheduleTime:-$1}
date=$(date +"%Y%m%d" -d "-1 day $today")
date_path=$(date +%Y/%m/%d -d "-1 day $today")
expire_date=$(date +%Y%m%d -d "-4 day $today")
expire_date_path=$(date +%Y/%m/%d -d "-4 day $today")

sleep 60

output_path="s3://mob-emr-test/dataplatform/DataWareHouse/data/dwh/etl_tracking_merge_daily/${date_path}"

spark-submit --class mobvista.dmp.datasource.datatory.TrackingMergeDaily \
     --conf spark.sql.shuffle.partitions=10 \
     --conf spark.default.parallelism=10 \
     --conf spark.sql.files.maxPartitionBytes=536870912 \
     --conf spark.executor.extraJavaOptions="-XX:+UseG1GC" \
     --files ${HIVE_SITE_PATH} \
     --jars ${JARS} \
     --master yarn --deploy-mode cluster --executor-memory 4g --driver-memory 4g  --executor-cores 2  --num-executors 5 \
     ../../${JAR} -date ${date} -output ${output_path}

if [[ $? -ne 0 ]]; then
    exit 255
fi

# 挂载分区
mount_partition "etl_tracking_merge_daily" "dt='${date}'" "${output_path}"