HASH
Description
HASH
is a row function that evenly partitions data values into the specified number of buckets. It creates a hash of the input value and assigns that value a bucket number. Equal values will always hash to the same bucket number.Syntax
HASH
(field_name
,INTEGER
)Return Value
Returns one value per row of type
INTEGER
corresponding to the bucket number that the input value hashes to.Input Parameters
- field_name
- Required. The name of the field whose values you want to partition. When this value is NULL and theINTEGERparameter is a value other than zero or NULL, the function returns zero, otherwise it returns NULL.
- integer
- Required. The desired number of buckets. This parameter can be a numeric value of any field type, but when it is a non-integer value, the value is truncated to an integer. When the value is zero or NULL, the function returns NULL. When the value is negative, the function uses absolute value.
Examples
Partition the values of the
username
field into 20 buckets:HASH([username],20)