Was this helpful?
Was this helpful?
Apache Pinot provides a suite of hash functions to compute various hash values for data transformation within queries. These functions support cryptographic hashes (e.g., SHA, MD5) and non-cryptographic hashes (e.g., Murmur, Adler, CRC). Below is a detailed reference for each function.
Computes the SHA-1 hash of the input.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
STRING
: SHA-1 hash as a lowercase hex string.
Example
Computes the SHA-224 hash of the input.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
STRING
: SHA-224 hash as a lowercase hex string.
Example
Computes the SHA-256 hash of the input.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
STRING
: SHA-256 hash as a lowercase hex string.
Example
Computes the SHA-512 hash of the input.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
STRING
: SHA-512 hash as a lowercase hex string.
Example
Computes the MD2 hash of the input.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
STRING
: MD2 hash as a lowercase hex string.
Example
Computes the MD5 hash of the input.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
STRING
: MD5 hash as a lowercase hex string.
Example
Computes a 32-bit MurmurHash2 value.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
INT
: 32-bit hash value (signed integer).
Example
Computes a 32-bit MurmurHash2 value for a UTF-8 string.
Syntax
Parameters
input
(STRING
): Input string (converted to UTF-8 bytes).
Returns
INT
: 32-bit hash value (signed integer).
Example
Computes a 64-bit MurmurHash2 value. Two overloads are supported:
Syntax 1 (No Seed)
Syntax 2 (With Seed)
Parameters
input
(BYTES
): Input byte array to hash.
seed
(INT
, optional): Seed value for the hash function.
Returns
LONG
: 64-bit hash value (signed long).
Examples
Computes a 32-bit MurmurHash3 value with a seed.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
seed
(INT
): Seed value for the hash function.
Returns
INT
: 32-bit hash value (signed integer).
Example
Computes a 64-bit MurmurHash3 value with a seed.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
seed
(INT
): Seed value for the hash function.
Returns
LONG
: 64-bit hash value (signed long).
Example
Computes a 128-bit MurmurHash3 value with a seed.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
seed
(INT
): Seed value for the hash function.
Returns
BYTES
: 128-bit hash as a 16-byte array.
Example
Computes a 32-bit MurmurHash3 optimized for x64 platforms.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
seed
(INT
): Seed value for the hash function.
Returns
INT
: 32-bit hash value (signed integer).
Example
Computes a 128-bit MurmurHash3 optimized for x64 platforms.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
seed
(INT
): Seed value for the hash function.
Returns
BYTES
: 128-bit hash as a 16-byte array.
Example
Computes a 32-bit Adler checksum.
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
INT
: 32-bit Adler checksum (signed integer).
Example
Computes a 32-bit CRC (Cyclic Redundancy Check).
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
INT
: 32-bit CRC32 value (signed integer).
Example
Computes a 32-bit CRC32C (Castagnoli).
Syntax
Parameters
input
(BYTES
): Input byte array to hash.
Returns
INT
: 32-bit CRC32C value (signed integer).
Example
Input Conversion: Use TO_UTF8(string)
to convert strings to BYTES
where required.
Negative Values: Hash functions return signed integers/longs. Use CAST
to interpret them as unsigned if needed.
Byte Arrays: Functions like MURMURHASH3BIT128
return BYTES
as a 16-byte array.
Platform-Specific Variants:
Functions like MURMURHASH3X64BIT32/64/128
are optimized for x64 architectures. The results could be different cross platform.