--- name: dogsled-model-spec-cleaning description: Author Model Spec cleaning expressions and entity-graph standardization transforms for dirty source data. --- # Model Spec Cleaning Use this skill when authoring staging models, applying profiler cleaning suggestions, or configuring entity-graph `standardize` transforms. ## Function Catalog | Function | Use | | ---------------------------------- | --------------------------------------------------------------------------------------- | | `nullif_empty(col)` | Convert blank strings to `NULL`. | | `normalize_email(col)` | Trim and lowercase emails. | | `normalize_email_uid2(col)` | UID2-compatible email normalization for Gmail/googlemail dot and plus-tag handling. | | `extract_email_domain(col)` | Derive account/domain keys from emails. | | `strip_email_subaddress(col)` | Remove `+tag` email subaddressing. | | `strip_accents(col)` | Remove accents before matching. | | `normalize_company(col)` | Clean company names with suffix/case/whitespace handling. | | `strip_trading_as(col)` | Remove d/b/a or trading-as aliases before company normalization. | | `extract_domain(col)` | Convert full URLs to comparable domains. | | `normalize_phone(col)` | Keep phone digits and remove leading US/Canada country code. | | `strip_phone_extension(col)` | Remove phone extensions before phone normalization. | | `normalize_state(col)` | Normalize US states to two-letter codes. | | `expand_street_abbreviations(col)` | Canonicalize USPS street suffixes, unit designators, and directionals. | | `normalize_street(col)` | Lowercase, strip punctuation, collapse whitespace, and canonicalize USPS street tokens. | | `normalize_postal(col)` | Normalize postal codes; US ZIP+4 reduces to ZIP5. | | `fingerprint(col)` | Build sorted/deduped entity-resolution blocking keys. | | `sha256(col)` | Terminal SHA-256 digest for non-keyed hashed values. | | `hmac_sha256(col)` | Terminal keyed match digest using `DOGSLED_MATCH_KEY_SECRET`. | | `parse_number(col)` | Parse formatted currency/number strings. | | `parse_date(col, format)` | Parse strings to dates/timestamps (`us`, `eu`, `iso8601`, etc.). | ## Canonical Chains - Company: `normalize_company(company_name)` or `normalize_company(strip_trading_as(company_name))`. - Email: `normalize_email(email)` and `extract_email_domain(normalize_email(email))`. - Privacy match key: `hmac_sha256(normalize_email_uid2(email))` for cross-party email joins when both parties use Dogsled's portable keyed construction. - Phone: `normalize_phone(strip_phone_extension(phone))` when extensions appear. - URL/domain: `extract_domain(lower(website_url))` for full URLs; `lower(strip_www(domain))` for bare domains. - State: `normalize_state(state)`. - Address: `normalize_street(street_address)` with `normalize_postal(postal_code)` for blocking/matching. - Dirty strings: `nullif_empty(collapse_whitespace(trim(value)))`. - Matching keys: `fingerprint(company_name)` for blocking or fuzzy candidate generation. ## Profiler Workflow Run `dogsled model profile suggest cleaning