diff --git a/jobs/refresh-derived-tables.yml b/jobs/refresh-derived-tables.yml index 02e11ea..8de70ec 100644 --- a/jobs/refresh-derived-tables.yml +++ b/jobs/refresh-derived-tables.yml @@ -2,6 +2,13 @@ type: "job-pipeline" description: "Refresh Derived Tables" configuration: jobs: + - type: "iterating-job" + description: "Create destination views and functions" + configuration: + jobTemplate: + path: "create-derived-table-in-warehouse.yml" + iterations: + - tableName: "current_pipeline_summary" - type: "iterating-job" description: "Create derived setup tables" configuration: diff --git a/jobs/sql/derivations/views/current_pipeline_summary.sql b/jobs/sql/derivations/views/current_pipeline_summary.sql new file mode 100644 index 0000000..6523356 --- /dev/null +++ b/jobs/sql/derivations/views/current_pipeline_summary.sql @@ -0,0 +1,44 @@ +DROP VIEW if exists current_pipeline_summary; +CREATE VIEW current_pipeline_summary AS +select max(cast(jparent.initiated as date)) as run_date, + max(j.status) as status, + count(*) as count, + null as description, + null as error_message, + min(j.started) as started, + max(j.completed) as completed, + null as uuid, + null as parent_child, + max(jparent.uuid) as parent_uuid +from petl_job_execution j +inner join petl_job_execution jparent on jparent.uuid = + (select top 1 uuid from petl_job_execution pje + where description in ('Refreshing HUMCI data','Refreshing ZL data') + order by initiated desc) +where j.initiated >= jparent.initiated +and j.status = 'SUCCEEDED' +group by j.status + +union + +select cast(jparent.initiated as date), + j.status, + null, + j.description, + j.error_message, + j.started, + j.completed, + j.uuid, +CASE + when ((j.description like 'Importing from%' and j.description like '% to %') or (j.description like 'Creating derived%')) + then 'child' + else 'parent' +END, +jparent.uuid as parent_uuid +from petl_job_execution j +inner join petl_job_execution jparent on jparent.uuid = + (select top 1 uuid from petl_job_execution pje + where description in ('Refreshing HUMCI data','Refreshing ZL data') + order by initiated desc) +where j.initiated >= jparent.initiated +and j.status <> 'SUCCEEDED';