This topic describes how to use the string function HASH_CODE in Realtime Compute.

Syntax

INT HASH_CODE(VARCHAR str)    

Input parameters

Parameter Data type
str VARCHAR

Description

Returns the absolute value of HASH_CODE() for a string.

Example

  • Test data
    str1 (VARCHAR) str2 (VARCHAR) nullstr (VARCHAR)
    k1=v1;k2=v2 k1:v1,k2:v2 null
  • Test statements
    SELECT  HASH_CODE(str1) as var1, HASH_CODE(str2) as var2, HASH_CODE(nullstr) as var3
    FROM T1;
  • Test results
    var1 (INT) var2 (INT) var3 (INT)
    1099348823 401392878 null