D8LooPFocus modeCODE WORKSPACE
For checkout events, expand the payload items array into one row per item: return event_id, user_id, and sku. Order by event_id, sku.
JOIN json_each(e.payload, '$.items') AS item, filter to checkout, select item.value AS sku.
Sample input
| event_id | user_id | event_name | payload |
|---|---|---|---|
| 2 | 1 | checkout | {"device":"ios","items":["SKU-A","SKU-B"]} |
| 4 | 2 | checkout | {"device":"web","items":["SKU-C"]} |
Expected output
| event_id | user_id | sku |
|---|---|---|
| 2 | 1 | SKU-A |
| 2 | 1 | SKU-B |
| 4 | 2 | SKU-C |
Constraints
Join json_each(payload, '$.items') to the events row, filter event_name = 'checkout', and select item.value AS sku. Order by event_id, sku.
Expected skills
Array expansion with json_each and reasoning about the new item grain.
Run the SQL query to inspect preview rows.