All Products
Search
Document Center

MaxCompute:MASK_HASH

Last Updated:Jul 24, 2023

Returns a hash value that is calculated by using a string expression that is specified by expr. If the values calculated by a string expression are the same, a consistent hash value is returned.

Syntax

mask_hash(<expr>)

Parameters

expr: required. A string expression that is used to calculate a hash value. The STRING, CHAR, VARCHAR, and BINARY types are supported.

Return value

A hash value that is calculated by using a string expression is returned. The fixed length of the hash value is 64 characters. If a non-string expression is used, the value null is returned. This rule also applies to the Hive-compatible mode.

Examples

Note

For non-string expressions, NULL is returned. The hash algorithm is SHA256. A hexadecimal string of 64 characters in length is returned.

-- Return a hash value for the string abc.
select mask_hash("abc");
-- The following result is returned:
+------------+
| _c0        |
+------------+
| ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad |
+------------+

-- The return value is null if a non-string expression is used.
select mask_hash(100);
-- The following result is returned:
+------------+
| _c0        |
+------------+
| NULL       |
+------------+

Related functions

MASK_HASH is a string function. For more information about functions related to string searches and conversion, see String functions.