Write an end-to-end PySpark script that produces a given output table from the input data.
Asked in the Round 1 stage. Two such questions were asked in round 1, per thread 1uv9sob.
customer_id, customer_name, customer_segment, completed_transaction_count, completed_amount, and activity_status.COMPLETED from 2025-01-01 through 2025-03-31. Include customers with no qualifying transactions.completed_amount descending, then customer_id ascending. completed_amount must be zero when no qualifying amount exists.| Column | Type | Description |
|---|---|---|
| customer_idPK | INTEGER | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| customer_segment | VARCHAR(60) | Customer segment classification |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| customer_id | INTEGER | Customer associated with the transaction |
| amount | NUMERIC(14,2) | Transaction amount |
| transaction_date | DATE | Date the transaction occurred |
| status | VARCHAR(60) | Transaction processing status |