This page explains how to use the hash function in APL.
hash
scalar function to transform any data type as a string of bytes into a signed integer. The result is deterministic so the value is always identical given the same input data.
Use the hash
function to:
hash
to generate values for long term usage. hash
is generic and the underlying hashing algorithm may change. For long term stability, use the other hash functions with specific algorithm like hash_sha1
.Splunk SPL users
hash
(or md5
, sha1
, etc.) returns a hexadecimal string and lets you pick an algorithm. In APL hash
always returns a 64-bit integer that trades cryptographic strength for speed and compactness. Use hash_sha256
if you need a cryptographically secure digest.ANSI SQL users
HASH
(BigQuery), HASH_BYTES
(SQL Server), or MD5
. These return either bytes or hex strings. In APL hash
always yields an int64
. To emulate SQL’s modulo bucketing, pipe the result into the arithmetic operator that you need.Name | Type | Description |
---|---|---|
valsourceue | scalar | Any scalar expression except real . |
salt | int | (Optional) Salt that lets you derive a different 64-bit domain while keeping determinism. |
source
(and salt
if supplied).
anon_id | requests |
---|---|
-5872831405421830129 | 128 |
902175364502087611 | 97 |
-354879610945237854 | 85 |
6423087105927348713 | 74 |
-919087345721004317 | 69 |