Queries · q114 · Data Protection Officer · week 1, night 1
“How many compliance incidents are being flagged each month by severity, how quickly are they resolved, and is an unresolved backlog building up?”
Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told
The manager, at the start of week 1
Subject: A few starting questions on privacy & data handling
Hi Priyanka,
Welcome aboard, and thank you for taking these on this week. As I get oriented, here's what I'd like to understand first. Given the slot constraints, please treat these as priorities in order — if only three fit this week, start from the top and we'll pick up the rest next week.
For now, could you scope the first request for me? I'd like to see it broken down in a way that shows me trend over the last several months, not just a single total — I want to catch whether we're improving or falling behind.
Let me know if any of these need to be split further once you see what the data looks like.
Thanks, Ines
The analyst · week 1, night 1, request 3 of 3
Ines asked me to scope item 1 first (DSAR volume/closure time/overdue, trended monthly) but also flagged items 2 and 3 as high priority and well-defined enough to start in parallel, since the week is tight (5 topics, 4 nights). None of these three depend on each other's results, so I'm running all as independent first-look reports tonight rather than waiting. I kept each to one grain and used a dimension-as-row-grain (purpose, severity) instead of guessing at unknown code values, per the carrier/month pattern in the handbook. Items 4 (retention vs. policy) and 5 (legal holds) are intentionally deferred to a later night since they need review of retention_policies/legal_holds structure first and aren't part of what Ines asked me to scope tonight.
The engineer · 2 dry runs on the empty schema, then the submission
SELECT to_char(date_trunc('month', occurred_at), 'YYYY-MM') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, round( (percentile_cont(0.5) within group (order by extract(epoch from (resolved_at - occurred_at))/86400.0) filter (where resolved))::numeric, 1 ) as median_days_to_resolve, count(*) filter ( where not resolved and (timestamp '2026-01-05' - occurred_at) > interval '30 days' ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1, 2
SELECT to_char(date_trunc('month', occurred_at), 'YYYY-MM') as month, strftime(date_trunc('month', occurred_at), '%Y-%m') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, round( (percentile_cont(0.5) within group (order by extract(epoch from (resolved_at - occurred_at))/86400.0) filter (where resolved))::numeric, 1 ) as median_days_to_resolve, count(*) filter ( where not resolved and (timestamp '2026-01-05' - occurred_at) > interval '30 days' ) as unresolved_over_30dFROM compliance_eventsWHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01'GROUP BY 1, 2ORDER BY 1, 2
“This compiles correctly with all requested columns. Submitting now.”
“Submitted. The report groups compliance_events by detection month (2023-01 through 2025-12) and the raw severity values, with detected/resolved/unresolved counts, the median resolution time in days for resolved incidents, and a backlog count of unresolved incidents older than 30 days as of 2026-01-05.”
As Priyanka Desai saw it, from the small dataset the agents worked on
month | severity | incidents_detected | resolved_count | unresolved_count | median_days_to_resolve | unresolved_over_30d --------+----------+--------------------+----------------+------------------+------------------------+-------------------- 2023-06 | medium | 1 | 1 | 0 | 3.7 | 0 2023-10 | medium | 1 | 1 | 0 | 18.1 | 0 2024-03 | medium | 1 | 1 | 0 | 20.7 | 0 2025-02 | high | 3 | 3 | 0 | 9.6 | 0 2025-02 | medium | 1 | 1 | 0 | 29.2 | 0 2025-10 | high | 1 | 1 | 0 | 0.1 | 0 (6 rows)
Changed only where the benchmark needs the same result on every system
SELECT strftime(date_trunc('month', occurred_at), '%Y-%m') as month, {{year_month(date_trunc('month', occurred_at))}} as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, round( (percentile_cont(0.5) within group (order by extract(epoch from (resolved_at - occurred_at))/86400.0) filter (where resolved))::numeric, 1 ) as median_days_to_resolve, ({{percentile_cont_filter(0.5, {{seconds_between(occurred_at, resolved_at)}}/86400.0, resolved)}}) as median_days_to_resolve, count(*) filter ( where not resolved and (timestamp '2026-01-05' - occurred_at) > interval '30 days' and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30dFROM compliance_eventsWHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01'GROUP BY 1, 2ORDER BY 1, 2ORDER BY 1 NULLS LAST, 2 NULLS LAST
SELECT strftime(date_trunc('month', occurred_at), '%Y-%m') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY CAST(EXTRACT(EPOCH FROM (resolved_at - occurred_at)) AS NUMERIC(18,6))/86400.0) FILTER (WHERE resolved)) as median_days_to_resolve, count(*) filter ( where not resolved and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1 NULLS LAST, 2 NULLS LAST
SELECT to_char(date_trunc('month', occurred_at), 'YYYY-MM') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY CASE WHEN resolved THEN CAST(EXTRACT(EPOCH FROM (resolved_at - occurred_at)) AS NUMERIC(18,6))/86400.0 END)) as median_days_to_resolve, count(*) filter ( where not resolved and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1 NULLS LAST, 2 NULLS LAST
SELECT to_char(CAST(date_trunc('month', occurred_at) AS timestamp), 'YYYY-MM') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY CAST(EXTRACT(EPOCH FROM (resolved_at - occurred_at)) AS NUMERIC(18,6))/86400.0) FILTER (WHERE resolved)) as median_days_to_resolve, count(*) filter ( where not resolved and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1 NULLS LAST, 2 NULLS LAST
SELECT to_char(date_trunc('month', occurred_at), 'YYYY-MM') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY CAST(EXTRACT(EPOCH FROM (resolved_at - occurred_at)) AS NUMERIC(18,6))/86400.0) FILTER (WHERE resolved)) as median_days_to_resolve, count(*) filter ( where not resolved and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1 NULLS LAST, 2 NULLS LAST
SELECT to_char(date_trunc('month', occurred_at), 'YYYY-MM') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY CAST(CAST(EXTRACT(EPOCH FROM (resolved_at - occurred_at)) AS NUMERIC(18,6))/86400.0 AS DOUBLE PRECISION)) FILTER (WHERE resolved)) as median_days_to_resolve, count(*) filter ( where not resolved and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1 NULLS LAST, 2 NULLS LAST
SELECT formatDateTime(date_trunc('month', occurred_at), '%Y-%m') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, (quantileExactInclusiveIf(0.5)(toFloat64(CAST(divideDecimal(toDecimal128(dateDiff('microsecond', occurred_at, resolved_at), 0), toDecimal128(1000000, 0), 6) AS Nullable(Decimal(18, 6)))/86400.0), resolved)) as median_days_to_resolve, count(*) filter ( where not resolved and occurred_at < TIMESTAMP '2026-01-05' - INTERVAL '30' DAY ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1 NULLS LAST, 2 NULLS LAST
The agents' own records, as the role play wrote them; only the personal data of the person who ran it is redacted
Report request from Priyanka Desai (analyst for the Data Protection Officer):
Title: Compliance events: monthly volume and resolution time by severity
Question: How many compliance incidents are being flagged each month by severity, how quickly are they resolved, and is an unresolved backlog building up?
Grain: one row per calendar month of detection (compliance_events.occurred_at) and severity level
Columns:
- month (YYYY-MM)
- severity
- incidents detected
- resolved count (resolved = true, as of 2026-01-05)
- unresolved count (resolved = false, as of 2026-01-05)
- median days to resolve (resolved_at - occurred_at, in days, for resolved=true rows only)
- unresolved and older than 30 days (resolved=false AND 2026-01-05 - occurred_at > 30 days)
Details: Source: compliance_events. Group by date_trunc('month', occurred_at) (or join calendar_days) and by the severity column as-is (do not assume specific severity strings — use whatever distinct values are present). Use the literal date 2026-01-05 as 'today' for all age/backlog calculations (never CURRENT_DATE/now()). Span 2023-01 through 2025-12. Platform-wide, all tenants. Order by month ascending, then severity.
Check your query with the warehouse's dry_run tool, then hand it in with submit.dry_runSELECT to_char(date_trunc('month', occurred_at), 'YYYY-MM') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, round( (percentile_cont(0.5) within group (order by extract(epoch from (resolved_at - occurred_at))/86400.0) filter (where resolved))::numeric, 1 ) as median_days_to_resolve, count(*) filter ( where not resolved and (timestamp '2026-01-05' - occurred_at) > interval '30 days' ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1, 2
STATUS: REJECTED - does not compile: Catalog Error: Scalar Function with name to_char does not exist!
dry_runSELECT strftime(date_trunc('month', occurred_at), '%Y-%m') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, round( (percentile_cont(0.5) within group (order by extract(epoch from (resolved_at - occurred_at))/86400.0) filter (where resolved))::numeric, 1 ) as median_days_to_resolve, count(*) filter ( where not resolved and (timestamp '2026-01-05' - occurred_at) > interval '30 days' ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1, 2
STATUS: COMPILES (dry run on the empty schema, no data read) COLUMNS: month, severity, incidents_detected, resolved_count, unresolved_count, median_days_to_resolve, unresolved_over_30d
submitSELECT strftime(date_trunc('month', occurred_at), '%Y-%m') as month, severity, count(*) as incidents_detected, count(*) filter (where resolved) as resolved_count, count(*) filter (where not resolved) as unresolved_count, round( (percentile_cont(0.5) within group (order by extract(epoch from (resolved_at - occurred_at))/86400.0) filter (where resolved))::numeric, 1 ) as median_days_to_resolve, count(*) filter ( where not resolved and (timestamp '2026-01-05' - occurred_at) > interval '30 days' ) as unresolved_over_30d FROM compliance_events WHERE occurred_at >= timestamp '2023-01-01' AND occurred_at < timestamp '2026-01-01' GROUP BY 1, 2 ORDER BY 1, 2
Submitted to tonight's batch. Your work on this request is done.