custom_classifier
!ADD_REGEX¶
- See also:
Adds categories and a regular expression to the custom classifier, while optionally specifying a regular expression for the column name and a comment.
Syntax¶
<custom_classifier>!ADD_REGEX(
'<semantic_category>' ,
'<privacy_category>' ,
'<value_regex>' ,
[ <column_name_regex> ] ,
[ <description> ] ,
[ <threshold> ]
)
Arguments¶
Required:
semantic_category
Specifies the identifier (name) for semantic category.
For details about semantic categories, see System tags and categories.
privacy_category
Specify one of the following values:
'IDENTIFIER'
,'QUASI_IDENTIFIER'
, or'SENSITIVE'
.For details about privacy categories, see System tags and categories.
value_regex
Specifies the regular expression to match the values in a column.
You can test the syntax of the regular expression by calling the REGEXP_LIKE function.
Optional:
column_name_regex
Specifies the regular expression to match the name of the column that you want to classify.
description
Specifies a comment for the values that you add to the instance.
threshold
Specifies the threshold value for the scoring rule.
The acceptable range is greater than
0.0
and less than or equal to1.0
.Default:
0.8
.
Output¶
Returns a status message indicating the association of the category with the custom classifier in this format:
classifier_name:category_name
.
Access control requirements¶
A role used to execute this SQL command must have the following privileges at a minimum:
Instance role |
Object |
Notes |
---|---|---|
|
The custom classification instance. |
The account role that calls this method must be granted this instance role on the custom classifier. By default, the account role used to create the instance can call this method. |
Note that operating on any object in a schema also requires the USAGE privilege on the parent database and schema.
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Usage notes¶
Calling this method multiple times gives an additive result for the number of regular expressions associated with the instance.
Call each method in a separate SQL statement (no method chaining).
All regular expression searches for classification purposes are case-insensitive.
Test the regular expression before adding a regular expression to the custom classification instance. For example, use the [ NOT ] REGEXP function to make sure that only values that match the regex are returned in the result:
SELECT <col_to_classify> FROM <table_with_col_to_classify> WHERE <col_to_classify> REGEXP('<regex>');
For details, see String functions (regular expressions).
Examples¶
Add categories and a regular expression to the medical_codes
instance:
CALL medical_codes!ADD_REGEX(
'ICD_10_CODES',
'IDENTIFIER',
'[A-TV-Z][0-9][0-9AB]\.?[0-9A-TV-Z]{0,4}',
'ICD.*',
'Add a regex to identify ICD-10 medical codes in a column',
0.8,
);
Returns:
+---------------+
| ADD_REGEX |
+---------------+
| ICD_10_CODES |
+---------------+