Write a script that cleans a dataset by removing duplicates and filling in missing values.
Use the provided event and customer tables. Keep the latest record for each source event key, fill missing usage values with zero, and use the customer default plan when available.
source_event_key, customer_id, event_date, usage_units, plan_nameUnknown and order by source_event_key| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique ingestion record identifier |
| source_event_key | VARCHAR(30) | Business key used to identify duplicate events |
| customer_id | INT | Customer associated with the event |
| event_date | DATE | Date on which usage occurred |
| usage_units | INT | Usage units recorded for the event |
| plan_name | VARCHAR(40) | Plan recorded in the event source |
| ingested_at | TIMESTAMP | Timestamp when the record was ingested |
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| default_plan | VARCHAR(40) | Fallback plan assigned to the customer |