{% macro get_workflow_status() %} {% if execute %} {% set run_sql %} select case when sum(case when tht.load_successful in ('W','Y') then 0 else 1 end) = 0 then 'Y' else 'N' end status from {{ source('control_tables','A_WORKFLOW_HISTORY') }} wh join {{ source('control_tables','A_TASK_HISTORY') }} th on wh.a_workflow_history_key = th.a_workflow_history_key and wh.service_name = th.service_name join {{ source('control_tables','A_TASK_HISTORY_TARGET') }} tht on th.a_task_history_key = tht.a_task_history_key and th.service_name = tht.service_name where wh.service_name = '{{ var("input_service_name") }}' and wh.workflow_name = '{{ var("workflow_name") }}' and wh.orchestration_run_id = '{{ var("orchestration_run_id") }}' {% endset %} {% set res = run_query(run_sql) %} {% set status = res.columns[0].values()[0] %} {{ return(status) }} {% endif %} {% endmacro %}