CODE WORKSPACE

Detect upsert key violations

Find null and duplicate unique keys that would make an upsert unsafe.

The SQL API will hydrate this workspace with the exercise-specific starter query and schema.

Sample input

customer_stageThe merge/upsert key must identify one target row. Here customer_id 104 is duplicated and one row has no key.
customer_idemailupdated_at
104dee-old@example.com2026-03-05 09:00:00
104dee@example.com2026-03-05 12:30:00
nullghost@example.com2026-03-05 13:00:00

Expected output

Expected outputReport unsafe keys before any merge: duplicate customer 104 and one NULL key.
issue_typecustomer_keyrows_in_batch
duplicate_key1042
null_key<NULL>1

Constraints

Load the live SQL exercise to inspect the full prompt, schema, starter query, and expected output.

Expected skills

Upserts, Unique keys, HAVING

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.