Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 11 additions & 4 deletions src/ingestion/gold/metric_entity_cohorts_current.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ''
Expand Down
2 changes: 1 addition & 1 deletion src/ingestion/scripts/connectors-ddl/insight.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/ingestion/scripts/connectors-ddl/silver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading