mask
mask replaces entity characters with a masking character. Use it for partial redaction when you need to hide selected characters while preserving useful structure such as length, separators, or visible prefixes.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
masking_char | STRING (1 char) | "*" | Character used for masking. |
chars_to_mask | INT | null | How many characters to mask. null (omitted) = mask all; 0 = mask none; positive N = mask N characters. |
from_end | BOOLEAN | true | When chars_to_mask is set, count from the end of the value. Set false to count from the start. |
mask_all_chars | BOOLEAN | false | When false, only alphanumeric characters are masked (separators like - and spaces are preserved). When true, every character position is masked, including separators. |
Example — full mask
Section titled “Example — full mask”SELECT app_public.mask( 'SSN: 078-05-1120, Card: 4532-7891-2345-6672', OBJECT_CONSTRUCT( 'entity_config', OBJECT_CONSTRUCT( 'US_SSN', OBJECT_CONSTRUCT('operator', 'mask'), 'CREDIT_CARD', OBJECT_CONSTRUCT( 'operator', 'mask', 'operator_params', OBJECT_CONSTRUCT('masking_char', 'X') ) ) ));-- SSN: ***-**-****, Card: XXXX-XXXX-XXXX-XXXXExample — mask last 4 digits only
Section titled “Example — mask last 4 digits only”Use this when a workflow needs to hide the trailing digits while leaving the rest of the value visible:
SELECT app_public.mask( 'Phone: 415-555-0100', OBJECT_CONSTRUCT( 'entity_config', OBJECT_CONSTRUCT( 'PHONE_NUMBER', OBJECT_CONSTRUCT( 'operator', 'mask', 'operator_params', OBJECT_CONSTRUCT( 'masking_char', 'X', 'chars_to_mask', 4, 'from_end', TRUE ) ) ) ));-- Phone: 415-555-XXXXExample — mask_all_chars for uniform output
Section titled “Example — mask_all_chars for uniform output”Mask every position, including separators. This hides punctuation and spacing, but the output still preserves entity length:
SELECT app_public.mask( 'SSN: 078-05-1120', OBJECT_CONSTRUCT( 'entity_config', OBJECT_CONSTRUCT( 'US_SSN', OBJECT_CONSTRUCT( 'operator', 'mask', 'operator_params', OBJECT_CONSTRUCT('mask_all_chars', TRUE) ) ) ));-- SSN: ***********When to use
Section titled “When to use”- Workflows that require masking specific portions of credit card numbers, phone numbers, or other structured identifiers.
- Partial redaction where reviewers need to see length or format while selected characters are hidden.
- When downstream workflows do not need stable replacement values for joins or grouping.
masking_charmust be exactly 1 character.- When
chars_to_mask > len(entity), the entire entity is masked. - Masked output preserves original length —
***-**-****is the same length as078-05-1120. - Partial masking can leave unmasked characters, length, and format visible. Use a stricter operator, such as
constantorhash, when that remaining structure should not be exposed.