Explode a nested order payload into one row per line item, carrying the order-level attributes down onto every row.
order_id, customer_id, ordered_at, sku, quantity, unit_price, line_totalline_total is quantity * unit_price, rounded to two decimalspayloads| items | order_id | ordered_at | customer_id |
|---|---|---|---|
| [{"sku":"A1","quantity":2,"unit_price":5},{"sku":"B2","quantity":1,"unit_price":12.5}] | 1 | 2024-01-01 09:00:00 | 10 |
| order_id | customer_id | ordered_at | sku | quantity | unit_price | line_total |
|---|---|---|---|---|---|---|
| 1 | 10 | 2024-01-01 09:00:00 | A1 | 2 | 5 | 10 |
| 1 | 10 | 2024-01-01 09:00:00 | B2 | 1 | 12.5 | 12.5 |
payloads| items | order_id | ordered_at | customer_id |
|---|---|---|---|
| [{"sku":"X","quantity":1,"unit_price":3}] | 1 | 2024-02-01 00:00:00 | 7 |
| [{"sku":"Y","quantity":3,"unit_price":2}] | 2 | 2024-02-02 00:00:00 | 8 |
| order_id | customer_id | ordered_at | sku | quantity | unit_price | line_total |
|---|---|---|---|---|---|---|
| 1 | 7 | 2024-02-01 00:00:00 | X | 1 | 3 | 3 |
| 2 | 8 | 2024-02-02 00:00:00 | Y | 3 | 2 | 6 |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.