aba_re_run_month.py 1.32 KB
import os
import sys

sys.path.append(os.path.dirname(sys.path[0]))
from utils.DolphinschedulerHelper import DolphinschedulerHelper
from utils.common_util import CommonUtil
from utils.spark_util import SparkUtil


if __name__ == '__main__':
    start_date = CommonUtil.get_sys_arg(1, None)
    end_date = CommonUtil.get_sys_arg(2, None)

    spark_session = SparkUtil.get_spark_session("re-run-aba-month")

    sql = f"""
    select distinct year_month as date_info from dim_date_20_to_30 where year_month >= '{start_date}' and year_month < '{end_date}';
    """
    date_df = spark_session.sql(sql)

    print(date_df.show())

    date_list = sorted([d.asDict().get("date_info") for d in date_df.collect()])

    print(date_list)

    for date_info in date_list:
        startParams = {
            "site_name": "us",
            "date_type": "month",
            "date_info": date_info
        }
        print(startParams)
        DolphinschedulerHelper.start_and_watch_process_instance(
            "big_data_selection",
            process_df_name='月-重跑ABA四分位',
            startParams={
                "site_name": "us",
                "date_type": "month",
                "date_info": date_info
            }
        )

    CommonUtil.send_wx_msg(["huangjian", "chenyuanjie"], "【月-重跑ABA四分位】重跑完成", "")

    pass