Skip to content

normalize_status

Normalizes platform-specific status values to a unified standard set of UPPER CASE values.

Signature

sql
normalize_status(raw_status STRING) RETURNS STRING

Parameters

ParameterTypeDescription
raw_statusSTRINGRaw status value from any platform's status table

Return Values

Normalized ValueDescription
ACTIVECampaign/ad group/ad is currently active and serving
PAUSEDManually paused by the advertiser
REMOVEDPermanently removed (Google only)
COMPLETEDCampaign finished its scheduled run (LinkedIn, 6sense)
NULLUnknown or unrecognized status value

Normalization Mapping

PlatformRaw ValueNormalized
GoogleENABLEDACTIVE
GooglePAUSEDPAUSED
GoogleREMOVEDREMOVED
MicrosoftActiveACTIVE
MicrosoftPausedPAUSED
LinkedInACTIVEACTIVE
LinkedInPAUSEDPAUSED
LinkedInCOMPLETEDCOMPLETED
RedditACTIVEACTIVE
6senseActiveACTIVE
6senseCompletedCOMPLETED

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 CampaignStatus

Design Notes

  • Case-insensitive: Uses UPPER() internally, so Active, ACTIVE, and active all normalize the same way
  • NULL-safe: Returns NULL for 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_v2 view (5 status table JOINs)

Source

sql/customer_ads_suse/routines/normalize_status.sql

SUSE Paid Advertising Data Warehouse V2