surfacecleaninganonymize
Cleaningscalar · returns varchar

ANONYMIZE

Remove or mask personally identifiable information from text

Per-row — runs once for each row.

cleaningllmtext

Syntax

ANONYMIZE({{ value }})
ANONYMIZE({{ value }}, '{{ mode }}')
ANONYMIZE({{ value }}, '{{ mode }}', '{{ pii_types }}')

Arguments

nametypedescription
valueVARCHAR
mode(optional)VARCHARMode: redact ([REDACTED]), mask (j***@...), fake (realistic replacement), hash
pii_types(optional)VARCHARPII types: name,email,phone,ssn,address,dob,credit_card,ip (comma-separated or 'all')

About

Remove or mask personally identifiable information (PII) from a text value — names, emails, phone numbers, addresses, SSNs, and more. Useful when you need to share data externally, train a model, run analytics, or move a dataset into a less-trusted environment without leaking identifying details. Essential for GDPR, HIPAA, and CCPA workflows. Control the behavior with optional arguments: `mode` picks how PII gets handled (redact, mask, replace with synthetic values) and `pii_types` narrows the scan to specific categories.

Examples

Name should be redacted

SELECT
  anonymize ('John Smith, john@email.com')

Phone should be redacted

SELECT
  anonymize ('Call me at 555-123-4567')

Nearby rabbit holes

same domain
Climb back to The Looking Glass