How do you ensure data quality and consistency in a high-volume pipeline?
Write a PostgreSQL query that audits each pipeline batch for completeness and record-level quality issues. Return every batch, including batches with no ingested records, and classify each batch as passing or failing.
quality_status.batch_date, then batch_id.| Column | Type | Description |
|---|---|---|
| batch_idPK | INT | Unique pipeline batch identifier |
| source_name | VARCHAR(50) | Name of the upstream data source |
| batch_date | DATE | Date assigned to the pipeline batch |
| expected_event_count | INT | Expected number of events in the batch |
| Column | Type | Description |
|---|---|---|
| event_idPK | BIGINT | Unique ingested event row identifier |
| batch_id | INT | Pipeline batch containing the event |
| event_key | VARCHAR(80) | Source event identifier expected to be unique within a batch |
| event_ts | TIMESTAMP | Timestamp supplied by the source |
| amount | NUMERIC(12,2) | Non-negative event amount |
| status | VARCHAR(20) | Event processing status |