Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks SQL
Databricks Runtime 12.2 LTS and above
Returns a masked version of the input str.
In Databricks SQL and Databricks Runtime 13.3 LTS and above this function supports named parameter invocation.
Syntax
mask(str [, upperChar [, lowerChar [, digitChar [, otherChar ] ] ] ] )
Arguments
str: ASTRINGexpression.upperChar: A single characterSTRINGliteral used to substitute upper case characters. The default is'X'. IfupperCharisNULL, upper case characters remain unmasked.lowerChar: A single characterSTRINGliteral used to substitute lower case characters. The default is'x'. IflowerCharisNULL, lower case characters remain unmasked.digitChar: A single characterSTRINGliteral used to substitute digits. The default is'n'. IfdigitCharisNULL, digits remain unmasked.otherChar: A single characterSTRINGliteral used to substitute any other character. The default isNULL, which leaves these characters unmasked.
Returns
A STRING.
Examples
> SELECT mask('AaBb123-&^ % 서울 Ä');
XxXxnnn-&^ % 서울 X
> SELECT mask('AaBb123-&^ % 서울 Ä', 'Z', 'z', '9', 'X');
ZzZz999XXXXXXXXXZ
> SELECT mask('AaBb123-&^ % 서울 Ä', lowerChar => 'z', otherChar => 'X');
AzBz123XXXXXXXXXÄ
> SELECT mask('AaBb123-&^ % 서울 Ä', otherChar => '?');
AaBb123?????????Ä
> SELECT mask('AaBb123-&^ % 서울 Ä', NULL, NULL, NULL, NULL);
AaBb123-&^ % 서울 Ä