Categories:

String & binary functions (AI Functions)

AI_REDACT

Redacts personally identifiable information (PII) from unstructured text data.

Syntax

AI_REDACT( <input> [,  <categories> ] [, <return_error_details> ] )
Copy

Arguments

Required:

input

A VARCHAR value containing text data that may contain personally-identifiable information (PII).

Optional:

categories

An ARRAY of string values that specify the types of PII to be redacted. If not specified, all supported PII categories are redacted. See Detected PII categories for a list of supported categories.

Passing an unsupported category results in an error.

return_error_details

A BOOLEAN flag that indicates whether to return error details in case of error. When set to TRUE, the function returns an OBJECT that contains the value and the error message, one of which is NULL depending on whether the function succeeded or failed.

Requires that the session parameter AI_SQL_ERROR_HANDLING_USE_FAIL_ON_ERROR to be set to FALSE.

Returns

Generally, a VARCHAR containing placeholder values in place of redacted PII, such as [NAME] where the input text had “John Smith”.

If the session parameter AI_SQL_ERROR_HANDLING_USE_FAIL_ON_ERROR is set to FALSE and the optional argument return_error_details is set to FALSE or is not passed, and the function cannot process the input, the function returns NULL.

If the session parameter AI_SQL_ERROR_HANDLING_USE_FAIL_ON_ERROR is set to FALSE and the optional argument return_error_details is set to TRUE, the function returns an OBJECT with the following fields:

  • value: A VARCHAR value that contains the redacted text, or NULL if an error occurred.

  • error: A VARCHAR value that contains the error message if an error occurred, or NULL if the function succeeded.

Usage notes

Examples

See Examples.