diff --git a/src/ingestion/connectors/hr-directory/active-directory/dbt/active_directory__to_class_people.sql b/src/ingestion/connectors/hr-directory/active-directory/dbt/active_directory__to_class_people.sql index d8b4f378d..9d608bc2e 100644 --- a/src/ingestion/connectors/hr-directory/active-directory/dbt/active_directory__to_class_people.sql +++ b/src/ingestion/connectors/hr-directory/active-directory/dbt/active_directory__to_class_people.sql @@ -32,8 +32,12 @@ SELECT -- Prefer `mail` as canonical address; fall back to UPN when mail unset. coalesce(u.mail, u.userPrincipalName) AS email, u.jobTitle AS job_title, + -- `department_name` is the org cohort key for this class. There is no + -- org-unit UUID anywhere in the system (no `org_units` table exists), so + -- the former always-NULL `org_unit_id Nullable(UUID)` column was dropped. + -- Downstream `org_unit_id` (insight.people, gold views, the frontend) is a + -- department NAME string derived from this field. u.department AS department_name, - CAST(NULL AS Nullable(UUID)) AS org_unit_id, -- manager_person_id is the resolved unified person ID, not an AD source ID. -- Leave it null here; Silver Step 2 (Identity Manager) resolves it from the -- parent_id/parent_email identity_inputs signals emitted by diff --git a/src/ingestion/connectors/hr-directory/bamboohr/dbt/bamboohr__to_class_people.sql b/src/ingestion/connectors/hr-directory/bamboohr/dbt/bamboohr__to_class_people.sql index d377ae918..6e9044664 100644 --- a/src/ingestion/connectors/hr-directory/bamboohr/dbt/bamboohr__to_class_people.sql +++ b/src/ingestion/connectors/hr-directory/bamboohr/dbt/bamboohr__to_class_people.sql @@ -30,8 +30,12 @@ SELECT lastName AS last_name, workEmail AS email, jobTitle AS job_title, + -- `department_name` is the org cohort key for this class. There is no + -- org-unit UUID anywhere in the system (no `org_units` table exists), so + -- the former always-NULL `org_unit_id Nullable(UUID)` column was dropped. + -- Downstream `org_unit_id` (insight.people, gold views, the frontend) is a + -- department NAME string derived from this field. department AS department_name, - CAST(NULL AS Nullable(UUID)) AS org_unit_id, supervisorEId AS manager_person_id, CASE WHEN status = 'Active' THEN 'active' diff --git a/src/ingestion/connectors/hr-directory/ms-entra/dbt/ms_entra__to_class_people.sql b/src/ingestion/connectors/hr-directory/ms-entra/dbt/ms_entra__to_class_people.sql index 00ec1522b..c8a307ce0 100644 --- a/src/ingestion/connectors/hr-directory/ms-entra/dbt/ms_entra__to_class_people.sql +++ b/src/ingestion/connectors/hr-directory/ms-entra/dbt/ms_entra__to_class_people.sql @@ -33,8 +33,12 @@ SELECT -- (common for guest/external users). coalesce(mail, userPrincipalName) AS email, jobTitle AS job_title, + -- `department_name` is the org cohort key for this class. There is no + -- org-unit UUID anywhere in the system (no `org_units` table exists), so + -- the former always-NULL `org_unit_id Nullable(UUID)` column was dropped. + -- Downstream `org_unit_id` (insight.people, gold views, the frontend) is a + -- department NAME string derived from this field. department AS department_name, - CAST(NULL AS Nullable(UUID)) AS org_unit_id, -- Manager relationships are not collected in v1 of the connector; -- a future iteration will add `$expand=manager` to populate this. CAST(NULL AS Nullable(String)) AS manager_person_id, diff --git a/src/ingestion/connectors/hr-directory/workday/dbt/workday__to_class_people.sql b/src/ingestion/connectors/hr-directory/workday/dbt/workday__to_class_people.sql index 73d120436..e53e8fa77 100644 --- a/src/ingestion/connectors/hr-directory/workday/dbt/workday__to_class_people.sql +++ b/src/ingestion/connectors/hr-directory/workday/dbt/workday__to_class_people.sql @@ -32,8 +32,12 @@ SELECT Business_Title AS job_title, -- Workday has no freeform department; the supervisory organization is the -- standard org unit every tenant is guaranteed to have. + -- `department_name` is the org cohort key for this class. There is no + -- org-unit UUID anywhere in the system (no `org_units` table exists), so + -- the former always-NULL `org_unit_id Nullable(UUID)` column was dropped. + -- Downstream `org_unit_id` (insight.people, gold views, the frontend) is a + -- department NAME string derived from this field. Supervisory_Organization AS department_name, - CAST(NULL AS Nullable(UUID)) AS org_unit_id, Manager_Employee_ID AS manager_person_id, multiIf( Worker_Status = 'Terminated', 'terminated', diff --git a/src/ingestion/gold/metric_entity_cohorts_current.sql b/src/ingestion/gold/metric_entity_cohorts_current.sql index 9fa149816..447b5891a 100644 --- a/src/ingestion/gold/metric_entity_cohorts_current.sql +++ b/src/ingestion/gold/metric_entity_cohorts_current.sql @@ -21,10 +21,17 @@ FROM ( SELECT workspace_id AS tenant_id, lower(assumeNotNull(email)) AS entity_id, - coalesce( - nullIf(toString(org_unit_id), ''), - nullIf(department_name, '') - ) AS cohort_id + -- The org cohort is keyed by department NAME, matching what the rest of + -- the serving path calls `org_unit_id` (insight.people projects + -- `argMax(department)` under that name, and the frontend round-trips the + -- value back as `org_unit_id in ('Engineering', …)`). This used to + -- coalesce a `class_people.org_unit_id Nullable(UUID)` column ahead of + -- the name; that column was always NULL (no `org_units` table exists) and + -- has been dropped. Do NOT reintroduce a UUID branch here without + -- migrating insight.people and the frontend in the same change — a + -- coalesce that prefers UUIDs would emit cohort ids the frontend never + -- sends, silently emptying every peer metric. + nullIf(department_name, '') AS cohort_id FROM {{ ref('class_people') }} WHERE email IS NOT NULL AND email != '' diff --git a/src/ingestion/scripts/connectors-ddl/insight.sql b/src/ingestion/scripts/connectors-ddl/insight.sql index 8ea203dd2..2ec1dc9ea 100644 --- a/src/ingestion/scripts/connectors-ddl/insight.sql +++ b/src/ingestion/scripts/connectors-ddl/insight.sql @@ -2726,7 +2726,7 @@ FROM SELECT workspace_id AS tenant_id, lower(assumeNotNull(email)) AS entity_id, - coalesce(nullIf(toString(org_unit_id), ''), nullIf(department_name, '')) AS cohort_id + nullIf(department_name, '') AS cohort_id FROM silver.class_people WHERE (email IS NOT NULL) AND (email != '') AND (workspace_id IS NOT NULL) AND (workspace_id != '') ORDER BY diff --git a/src/ingestion/scripts/connectors-ddl/silver.sql b/src/ingestion/scripts/connectors-ddl/silver.sql index 0c5099d13..5a60ef6fa 100644 --- a/src/ingestion/scripts/connectors-ddl/silver.sql +++ b/src/ingestion/scripts/connectors-ddl/silver.sql @@ -642,7 +642,6 @@ CREATE TABLE IF NOT EXISTS silver.class_people `email` Nullable(String), `job_title` Nullable(String), `department_name` Nullable(String), - `org_unit_id` Nullable(UUID), `manager_person_id` Nullable(String), `status` String, `employment_type` String,