Skip to main content
Version: v3

Data Masking Functions

Canner Enterprise currently provides built-in data masking functions, allowing users to directly use these functions to mask personal data during data analysis, in order to protect sensitive data.

Currently, the supported types of personal data that can be masked include:

  • Address
  • Phone Number
  • Name
  • Date of Birth
  • Identification Number
  • Email

Data Masking Functions

In Canner Enterprise, you can use redact to replace original data, such as replacing phone numbers with * symbols. Currently, the following types of replacement methods are supported:

1. redact(string, pattern, replacement)

Redact the value with the replacement if matching the pattern that includes a regular expression or a built-in pattern.

regular expression

demo=> select redact('johndoe@example.com','^(.*)@(.*)$', '*****@***.com');
redact
---------------
*****@***.com
(1 row)

built-in pattern

Refer for all built-in patterns.

demo=> select redact('johndoe@example.com','EMAIL_NAME', '*****');
redact
-------------------
*****@example.com
(1 row)

2. redact(string, struct)

Redact the value by the struct that is a JSON object with a pattern as key and a replacement as value. Here is an example of struct: {"EMAIL_NAME":"OOO", "^(.)([0-9]{3})(.+)$": "XXXX"}

demo=> select redact('johndoe@example.com','{"EMAIL_NAME":"*****","EMAIL_DOMAIN_LAST_3_PRESERVED":"yyds."}');
redact
----------------
*****@yyds.com
(1 row)

Built-in pattern

CategoryPattern NameInputOutputReplacement
AddressTAIWAN_ADDRESS_WITH_CITY_AND_DISTRICT_AND_STREET_KEPT台北市中正區忠孝東路一段1號台北市中正區忠孝東路一段**
AddressTAIWAN_ADDRESS_WITH_CITY_AND_DISTRICT_KEPT台北市中正區忠孝東路一段1號台北市中正區**
AddressTAIWAN_ADDRESS_WITH_CITY_KEPT台北市中正區忠孝東路一段1號台北市**
AddressADDRESS_WITH_COUNTRY_ZIPCODE_STATE_KEPT725 5th Ave, New York, NY 10022, United States*, *, NY 10022, United States*
AddressADDRESS_WITH_COUNTRY_KEPT725 5th Ave, New York, NY 10022, United States*, *, * *, United States*
Phone NumberTAIWAN_PHONE_NUMBER091234567809**
Phone NumberPHONE_NUMBER_WITH_LAST_3_KEPT886912345678*678*
Phone NumberPHONE_NUMBER_WITH_LAST_4_KEPT02 2321 4311*4311*
Phone NumberPHONE_NUMBER_WITH_COUNTRY_CODE_KEPT+886912345678+886**
NameCHINESE_NAME_SECOND_CHAR王大錘**
NameCHINESE_NAME_LAST_PRESERVED王大錘**
NameCHINESE_NAME_FIRST_PRESERVED王大錘**
NameLAST_NAME_PRESERVEDJohn Doe* Doe*
NameFIRST_NAME_PRESERVEDJohn DoeJohn **
Date of BirthDATE_OF_BIRTH_WITH_MONTH_AND_DAY_KEPT_ROC_ERA84/04/01*/04/01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_AND_DAY_KEPT_ROC_ERA84/04/0184/*/01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_AND_MONTH_KEPT_ROC_ERA84/04/0184/04/**
Date of BirthDATE_OF_BIRTH_WITH_DAY_KEPT_ROC_ERA84/04/01*/*/01*
Date of BirthDATE_OF_BIRTH_WITH_MONTH_KEPT_ROC_ERA84/04/01*/04/**
Date of BirthDATE_OF_BIRTH_WITH_YEAR_KEPT_ROC_ERA84/04/0184/*/**
Date of BirthDATE_OF_BIRTH_WITH_MONTH_AND_DAY_KEPT_ISO_86011970-01-01*-01-01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_AND_DAY_KEPT_ISO_86011970-01-011970-*-01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_AND_MONTH_KEPT_ISO_86011970-01-011970-01-**
Date of BirthDATE_OF_BIRTH_WITH_DAY_KEPT_ISO_86011970-01-01*-*-01*
Date of BirthDATE_OF_BIRTH_WITH_MONTH_KEPT_ISO_86011970-01-01*-01-**
Date of BirthDATE_OF_BIRTH_WITH_YEAR_KEPT_ISO_86011970-01-011970-*-**
Date of BirthDATE_OF_BIRTH_WITH_MONTH_AND_DAY_KEPT1970/01/01*/01/01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_AND_DAY_KEPT1970/01/011970/*/01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_AND_MONTH_KEPT1970/01/011970/01/**
Date of BirthDATE_OF_BIRTH_WITH_MONTH_KEPT1970/01/01*/01/**
Date of BirthDATE_OF_BIRTH_WITH_DAY_KEPT1970/01/01*/*/01*
Date of BirthDATE_OF_BIRTH_WITH_YEAR_KEPT1970/01/011970/*/**
Identification NumberTAIWAN_ID_NUMBER_KEEP_LETTER_AND_LAST_4_PRESERVEDF123456789F*6789*
Identification NumberTAIWAN_ID_NUMBER_LETTER_PRESERVEDF123456789F**
EmailEMAIL_DOMAIN_LAST_3_PRESERVEDjohndoe@example.comjohndoe@*com*
EmailEMAIL_DOMAIN_LAST_1_PRESERVEDjohndoe@example.comjohndoe@*m*
EmailEMAIL_DOMAIN_FIRST_3_PRESERVEDjohndoe@example.comjohndoe@exa**
EmailEMAIL_DOMAIN_FIRST_1_PRESERVEDjohndoe@example.comjohndoe@e**
EmailEMAIL_DOMAINjohndoe@example.comjohndoe@**
EmailEMAIL_NAME_LAST_3_PRESERVEDjohndoe@example.com*doe@example.com*
EmailEMAIL_NAME_LAST_1_PRESERVEDjohndoe@example.com*e@example.com*
EmailEMAIL_NAMEjohndoe@example.com*@example.com*
EmailEMAIL_NAME_FIRST_1_PRESERVEDjohndoe@example.comj*@example.com*
EmailEMAIL_NAME_FIRST_3_PRESERVEDjohndoe@example.comjoh*@example.com*