Appearance
normalize_status
Normalizes platform-specific status values to a unified standard set of UPPER CASE values.
Signature
sql
normalize_status(raw_status STRING) RETURNS STRINGParameters
| Parameter | Type | Description |
|---|---|---|
raw_status | STRING | Raw status value from any platform's status table |
Return Values
| Normalized Value | Description |
|---|---|
ACTIVE | Campaign/ad group/ad is currently active and serving |
PAUSED | Manually paused by the advertiser |
REMOVED | Permanently removed (Google only) |
COMPLETED | Campaign finished its scheduled run (LinkedIn, 6sense) |
NULL | Unknown or unrecognized status value |
Normalization Mapping
| Platform | Raw Value | Normalized |
|---|---|---|
ENABLED | ACTIVE | |
PAUSED | PAUSED | |
REMOVED | REMOVED | |
| Microsoft | Active | ACTIVE |
| Microsoft | Paused | PAUSED |
ACTIVE | ACTIVE | |
PAUSED | PAUSED | |
COMPLETED | COMPLETED | |
ACTIVE | ACTIVE | |
| 6sense | Active | ACTIVE |
| 6sense | Completed | COMPLETED |
Usage
sql
-- Direct usage
SELECT `customer_ads_suse.normalize_status`('ENABLED'); -- 'ACTIVE'
SELECT `customer_ads_suse.normalize_status`('Active'); -- 'ACTIVE'
SELECT `customer_ads_suse.normalize_status`(NULL); -- NULL
-- In unified_performance_v2 (with PAUSED default for missing rows)
COALESCE(`customer_ads_suse.normalize_status`(s.CampaignStatus), 'PAUSED') AS CampaignStatusDesign Notes
- Case-insensitive: Uses
UPPER()internally, soActive,ACTIVE, andactiveall normalize the same way - NULL-safe: Returns
NULLfor NULL or empty input (the COALESCE wrapper in the view handles the default) - Deterministic: Same input always produces the same output
- Used by:
unified_performance_v2view (5 status table JOINs)
Source
sql/customer_ads_suse/routines/normalize_status.sql