From 674e10268709ff30ef3b401ce2f068b909e1f7f7 Mon Sep 17 00:00:00 2001 From: Kevin Verhoff Date: Wed, 7 Feb 2024 19:47:35 +0000 Subject: [PATCH 1/7] renewal feed setup --- .../rpt_tableau__staff_renewal_feed.sql | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql diff --git a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql new file mode 100644 index 0000000000..3191cf9348 --- /dev/null +++ b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql @@ -0,0 +1,98 @@ +with + step_scales as ( + select + sr.employee_number, + pss.salary_rule, + pss.scale_cy_salary, + pss.scale_ny_salary, + pss.scale_step, + pss.school_level + from {{ ref("base_people__staff_roster") }} as sr + left join + {{ source("people", "src_people__salary_scale") }} as pss + on sr.job_title = pss.job_title + and sr.business_unit_assigned_name = pss.region + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + >= pss.scale_cy_salary + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + < pss.scale_ny_salary + and pss.school_level is null + where sr.assignment_status = 'Active' and pss.school_level is null + + union all + + select + sr.employee_number, + pss.salary_rule, + pss.scale_cy_salary, + pss.scale_ny_salary, + pss.scale_step, + pss.school_level + from {{ ref("base_people__staff_roster") }} as sr + left join + {{ source("people", "src_people__salary_scale") }} as pss + on sr.job_title = pss.job_title + and sr.business_unit_assigned_name = pss.region + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + >= pss.scale_cy_salary + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + < pss.scale_ny_salary + and pss.school_level = sr.home_work_location_grade_band + where + sr.assignment_status not in ('Terminated', 'Deceased') + and pss.school_level is not null + and sr.home_work_location_grade_band is not null + + ), + + pm_scores as ( + select internal_id, avg(overall_score) as pm4_overall_score, + from {{ ref("int_performance_management__observation_details") }} + where + form_term in ('PM2', 'PM3') + and overall_score is not null + and academic_year = functions.current_academic_year() + group by internal_id, academic_year + ) + +select + b.employee_number as df_employee_number, + b.legal_name_given_name as first_name, + b.legal_name_family_name as last_name, + b.preferred_name_given_name as preferred_first, + b.preferred_name_family_name as preferred_last, + b.preferred_name_lastfirst as preferred_name, + b.business_unit_home_name as legal_entity_name, + b.home_work_location_name as location_description, + b.department_home_name as home_department_description, + b.job_title as job_title_description, + b.assignment_status as position_status, + b.worker_original_hire_date as original_hire_date, + b.worker_rehire_date as rehire_date, + b.worker_termination_date as termination_date, + b.worker_type as worker_category_description, + b.worker_group_value as benefits_eligibility_class_description, + b.wage_law_coverage_short_name as flsa_description, + b.ethnicity_long_name as eeo_ethnic_description, + b.mail as mail, + b.user_principal_name as userprincipalname, + b.report_to_employee_number as manager_df_employee_number, + b.report_to_preferred_name_lastfirst as manager_name, + b.report_to_mail as manager_mail, + b.race_ethnicity_reporting, + b.gender_identity, + b.primary_grade_level_taught, + b.base_remuneration_annual_rate_amount_amount_value as base_salary, + + s.salary_rule, + s.scale_cy_salary, + s.scale_ny_salary, + s.scale_step, + s.school_level, + + p.pm4_overall_score, + +from {{ ref("base_people__staff_roster") }} as b +left join step_scales as s on b.employee_number = s.employee_number +left join pm_scores as p on b.employee_number = safe_cast(p.internal_id as int) +where b.assignment_status not in ('Terminated', 'Deceased') From f1972290f256ac5709721eadb2bdaceb05fe3111 Mon Sep 17 00:00:00 2001 From: Kevin Verhoff Date: Wed, 7 Feb 2024 20:59:36 +0000 Subject: [PATCH 2/7] trunk! --- .../extracts/tableau/rpt_tableau__staff_renewal_feed.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql index 3191cf9348..019d653945 100644 --- a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql +++ b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql @@ -6,7 +6,7 @@ with pss.scale_cy_salary, pss.scale_ny_salary, pss.scale_step, - pss.school_level + pss.school_level, from {{ ref("base_people__staff_roster") }} as sr left join {{ source("people", "src_people__salary_scale") }} as pss @@ -27,7 +27,7 @@ with pss.scale_cy_salary, pss.scale_ny_salary, pss.scale_step, - pss.school_level + pss.school_level, from {{ ref("base_people__staff_roster") }} as sr left join {{ source("people", "src_people__salary_scale") }} as pss @@ -52,7 +52,7 @@ with form_term in ('PM2', 'PM3') and overall_score is not null and academic_year = functions.current_academic_year() - group by internal_id, academic_year + group by internal_id ) select From bcdc3d85e41304e21fb7c47b5df8b8c71f93bf5e Mon Sep 17 00:00:00 2001 From: Kevin Verhoff Date: Thu, 15 Feb 2024 22:32:15 +0000 Subject: [PATCH 3/7] adding int view for expected ny salary --- .../int_people__expected_next_year_salary.sql | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql diff --git a/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql b/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql new file mode 100644 index 0000000000..c6d6ac40c5 --- /dev/null +++ b/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql @@ -0,0 +1,67 @@ +with + step_scales as ( + select + sr.employee_number, + sr.business_unit_assigned_code, + sr.job_title, + pss.salary_rule, + pss.scale_cy_salary, + pss.scale_ny_salary, + pss.scale_step, + pss.school_level, + from {{ ref("base_people__staff_roster") }} as sr + left join + {{ source("people", "src_people__salary_scale") }} as pss + on sr.job_title = pss.job_title + and sr.business_unit_assigned_name = pss.region + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + >= pss.scale_cy_salary + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + < pss.scale_ny_salary + and pss.school_level is null + where + sr.assignment_status not in ('Terminated', 'Deceased') + and pss.school_level is null + + union all + + select + sr.employee_number, + sr.business_unit_assigned_code, + sr.job_title, + pss.salary_rule, + pss.scale_cy_salary, + pss.scale_ny_salary, + pss.scale_step, + pss.school_level, + from {{ ref("base_people__staff_roster") }} as sr + left join + {{ source("people", "src_people__salary_scale") }} as pss + on sr.job_title = pss.job_title + and sr.business_unit_assigned_name = pss.region + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + >= pss.scale_cy_salary + and sr.base_remuneration_annual_rate_amount_amount_value + 150 + < pss.scale_ny_salary + and pss.school_level = sr.home_work_location_grade_band + where + sr.assignment_status not in ('Terminated', 'Deceased') + and pss.school_level is not null + and sr.home_work_location_grade_band is not null + + ) + +select + employee_number, + job_title, + scale_cy_salary, + scale_ny_salary, + scale_step, + case + when salary_rule is not null + then salary_rule + when job_title in ('Teacher', 'Teacher ESL', 'Learrning Specialist') + then concat('Teacher PM - ', business_unit_assigned_code) + else 'Annual Adjustment' + end as salary_rule, +from step_scales From 7249afbea8a90846844785249e8256b108ba5201 Mon Sep 17 00:00:00 2001 From: Kevin Verhoff Date: Fri, 16 Feb 2024 15:48:14 +0000 Subject: [PATCH 4/7] finalizing the view --- .../rpt_tableau__staff_renewal_feed.sql | 51 ++----------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql index 019d653945..1a4bb21d37 100644 --- a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql +++ b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql @@ -1,50 +1,4 @@ with - step_scales as ( - select - sr.employee_number, - pss.salary_rule, - pss.scale_cy_salary, - pss.scale_ny_salary, - pss.scale_step, - pss.school_level, - from {{ ref("base_people__staff_roster") }} as sr - left join - {{ source("people", "src_people__salary_scale") }} as pss - on sr.job_title = pss.job_title - and sr.business_unit_assigned_name = pss.region - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - >= pss.scale_cy_salary - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - < pss.scale_ny_salary - and pss.school_level is null - where sr.assignment_status = 'Active' and pss.school_level is null - - union all - - select - sr.employee_number, - pss.salary_rule, - pss.scale_cy_salary, - pss.scale_ny_salary, - pss.scale_step, - pss.school_level, - from {{ ref("base_people__staff_roster") }} as sr - left join - {{ source("people", "src_people__salary_scale") }} as pss - on sr.job_title = pss.job_title - and sr.business_unit_assigned_name = pss.region - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - >= pss.scale_cy_salary - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - < pss.scale_ny_salary - and pss.school_level = sr.home_work_location_grade_band - where - sr.assignment_status not in ('Terminated', 'Deceased') - and pss.school_level is not null - and sr.home_work_location_grade_band is not null - - ), - pm_scores as ( select internal_id, avg(overall_score) as pm4_overall_score, from {{ ref("int_performance_management__observation_details") }} @@ -88,11 +42,12 @@ select s.scale_cy_salary, s.scale_ny_salary, s.scale_step, - s.school_level, p.pm4_overall_score, from {{ ref("base_people__staff_roster") }} as b -left join step_scales as s on b.employee_number = s.employee_number +left join + {{ ref("int_people__expected_next_year_salary") }} as s + on b.employee_number = s.employee_number left join pm_scores as p on b.employee_number = safe_cast(p.internal_id as int) where b.assignment_status not in ('Terminated', 'Deceased') From 67cdfb836655400c997907b0454749b621e7d52b Mon Sep 17 00:00:00 2001 From: Kevin Verhoff Date: Fri, 16 Feb 2024 19:01:37 +0000 Subject: [PATCH 5/7] cleaning up a bit --- .../rpt_tableau__staff_renewal_feed.sql | 8 +- .../int_people__expected_next_year_salary.sql | 83 +++++-------------- 2 files changed, 25 insertions(+), 66 deletions(-) diff --git a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql index 1a4bb21d37..80071a3d01 100644 --- a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql +++ b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql @@ -1,11 +1,13 @@ with pm_scores as ( - select internal_id, avg(overall_score) as pm4_overall_score, + select + safe_cast(internal_id as int) as internal_id, + avg(overall_score) as pm4_overall_score, from {{ ref("int_performance_management__observation_details") }} where form_term in ('PM2', 'PM3') and overall_score is not null - and academic_year = functions.current_academic_year() + and academic_year = {{ var("current_academic_year") }} group by internal_id ) @@ -49,5 +51,5 @@ from {{ ref("base_people__staff_roster") }} as b left join {{ ref("int_people__expected_next_year_salary") }} as s on b.employee_number = s.employee_number -left join pm_scores as p on b.employee_number = safe_cast(p.internal_id as int) +left join pm_scores as p on b.employee_number = p.internal_id where b.assignment_status not in ('Terminated', 'Deceased') diff --git a/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql b/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql index c6d6ac40c5..6ddcba6209 100644 --- a/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql +++ b/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql @@ -1,67 +1,24 @@ -with - step_scales as ( - select - sr.employee_number, - sr.business_unit_assigned_code, - sr.job_title, - pss.salary_rule, - pss.scale_cy_salary, - pss.scale_ny_salary, - pss.scale_step, - pss.school_level, - from {{ ref("base_people__staff_roster") }} as sr - left join - {{ source("people", "src_people__salary_scale") }} as pss - on sr.job_title = pss.job_title - and sr.business_unit_assigned_name = pss.region - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - >= pss.scale_cy_salary - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - < pss.scale_ny_salary - and pss.school_level is null - where - sr.assignment_status not in ('Terminated', 'Deceased') - and pss.school_level is null - - union all - - select - sr.employee_number, - sr.business_unit_assigned_code, - sr.job_title, - pss.salary_rule, - pss.scale_cy_salary, - pss.scale_ny_salary, - pss.scale_step, - pss.school_level, - from {{ ref("base_people__staff_roster") }} as sr - left join - {{ source("people", "src_people__salary_scale") }} as pss - on sr.job_title = pss.job_title - and sr.business_unit_assigned_name = pss.region - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - >= pss.scale_cy_salary - and sr.base_remuneration_annual_rate_amount_amount_value + 150 - < pss.scale_ny_salary - and pss.school_level = sr.home_work_location_grade_band - where - sr.assignment_status not in ('Terminated', 'Deceased') - and pss.school_level is not null - and sr.home_work_location_grade_band is not null - - ) - select - employee_number, - job_title, - scale_cy_salary, - scale_ny_salary, - scale_step, + sr.employee_number, + sr.job_title, + sr.base_remuneration_annual_rate_amount_amount_value, + pss.scale_cy_salary, + pss.scale_ny_salary, + pss.scale_step, case - when salary_rule is not null - then salary_rule - when job_title in ('Teacher', 'Teacher ESL', 'Learrning Specialist') - then concat('Teacher PM - ', business_unit_assigned_code) + when pss.salary_rule is not null + then pss.salary_rule + when sr.job_title in ('Teacher', 'Teacher ESL', 'Learrning Specialist') + then concat('Teacher PM - ', sr.business_unit_assigned_code) else 'Annual Adjustment' end as salary_rule, -from step_scales +from {{ ref("base_people__staff_roster") }} as sr +left join + {{ ref("stg_people__salary_scale") }} as pss + on sr.job_title = pss.job_title + and sr.business_unit_assigned_name = pss.region + and sr.home_work_location_grade_band + = coalesce(pss.school_level, sr.home_work_location_grade_band) + and (sr.base_remuneration_annual_rate_amount_amount_value + 150) + between pss.scale_cy_salary and (pss.scale_ny_salary + 0.01) +where sr.assignment_status not in ('Terminated', 'Deceased') From db4e8845b863bc35ac5dc245b8e96974a8fccbd9 Mon Sep 17 00:00:00 2001 From: Charlie Bini <5003326+cbini@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:19:38 -0600 Subject: [PATCH 6/7] Update int_people__expected_next_year_salary.sql spacing --- .../intermediate/int_people__expected_next_year_salary.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql b/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql index 6ddcba6209..d7ae0615b7 100644 --- a/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql +++ b/src/dbt/kipptaf/models/people/intermediate/int_people__expected_next_year_salary.sql @@ -2,9 +2,11 @@ select sr.employee_number, sr.job_title, sr.base_remuneration_annual_rate_amount_amount_value, + pss.scale_cy_salary, pss.scale_ny_salary, pss.scale_step, + case when pss.salary_rule is not null then pss.salary_rule From 6b14c1014be4796ab6b5cdd306975d166d740643 Mon Sep 17 00:00:00 2001 From: Charlie Bini <5003326+cbini@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:20:43 -0600 Subject: [PATCH 7/7] Update rpt_tableau__staff_renewal_feed.sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💄 --- .../extracts/tableau/rpt_tableau__staff_renewal_feed.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql index 80071a3d01..273bb4e4ca 100644 --- a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql +++ b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__staff_renewal_feed.sql @@ -5,9 +5,9 @@ with avg(overall_score) as pm4_overall_score, from {{ ref("int_performance_management__observation_details") }} where - form_term in ('PM2', 'PM3') + academic_year = {{ var("current_academic_year") }} and overall_score is not null - and academic_year = {{ var("current_academic_year") }} + and form_term in ('PM2', 'PM3') group by internal_id ) @@ -46,7 +46,6 @@ select s.scale_step, p.pm4_overall_score, - from {{ ref("base_people__staff_roster") }} as b left join {{ ref("int_people__expected_next_year_salary") }} as s