Skip to main content
DB

Functions

Hash functions

28 Hash functions in NYXDB: names, aliases, signatures and behaviour.

28 functions. Names resolve case-insensitively; an alias binds the same function as its canonical name. Each entry gives the signatures, the behaviour and an example.

FunctionSummary
hash_blake3Produces the standard thirty-two-byte BLAKE3 digest for message contents.
hash_city_64Combines typed values into a repeatable 64-bit CityHash fingerprint.
hash_crc32Computes a 32-bit cyclic redundancy checksum for binary or UTF-8 input.
hash_farm_64Maps a sequence of typed arguments to the pinned FarmHash64 result.
hash_farm_fingerprint64Produces a portable FarmHash fingerprint from canonically encoded arguments.
hash_hiveCalculates the Hive-compatible signed checksum of a string’s encoded contents.
hash_hmacAuthenticates a message with a supplied key and a selected SHA-2 HMAC algorithm.
hash_int_32Scrambles one integer into a compact unsigned 32-bit hash value.
hash_int_64Derives an unsigned 64-bit mixing value directly from an integer.
hash_javaReproduces Java string hash codes using UTF-16 code units and wrapped signed arithmetic.
hash_keccak256Returns the Keccak-256 digest, using the pre-standardization padding convention.
hash_md5Returns the sixteen raw MD5 digest bytes for a string or binary message.
hash_murmur_2_32Calculates MurmurHash2’s 32-bit variant over a structured value sequence.
hash_murmur_2_64Returns the wide MurmurHash2 fingerprint for canonical typed inputs.
hash_murmur_3_128Generates sixteen raw fingerprint bytes using MurmurHash3 over typed values.
hash_murmur_3_32Compresses canonically serialized arguments with the 32-bit MurmurHash3 algorithm.
hash_murmur_3_64Computes a 64-bit MurmurHash3 result from the ordered argument encoding.
hash_sha1Builds a twenty-byte SHA-1 compatibility digest from message bytes.
hash_sha224Derives the SHA-224 digest as twenty-eight binary bytes.
hash_sha256Returns a 256-bit SHA-2 digest of binary data or UTF-8 text.
hash_sha384Calculates SHA-384 and exposes its forty-eight-byte binary digest.
hash_sha512Hashes a message with SHA-512 to obtain sixty-four raw bytes.
hash_sha512_256Computes the distinct SHA-512/256 construction for a thirty-two-byte result.
hash_sip_128Emits a sixteen-byte SipHash result for a sequence of structured arguments.
hash_sip_64Evaluates fixed-seed SipHash over one or more canonical SQL values.
hash_xx_32Creates a compact xxHash32 fingerprint from typed arguments.
hash_xx_64Computes the classic xxHash64 checksum over canonical value encodings.
hash_xxh3Fingerprints typed SQL values with the newer 64-bit XXH3 algorithm.

hash_blake3

Produces the standard thirty-two-byte BLAKE3 digest for message contents.

hash_blake3(bytes|string) -> fixed_string(32)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(32)
Aliasesblake3
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Uses the ordinary unkeyed BLAKE3 hashing mode and returns fixed_string(32). Bytes are consumed directly and string input is UTF-8; neither extended output nor keyed mode is implied by this overload. NULL yields NULL and incompatible message types raise TYPE_MISMATCH; the algorithm remains a deferred implementation contract.

Example

length(hash_blake3('abc'))
-- → 32

hash_city_64

Combines typed values into a repeatable 64-bit CityHash fingerprint.

hash_city_64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasescity_hash64, cityHash64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Hashes the canonical typed encoding of all arguments with a pinned CityHash64 version. Type boundaries participate, so concatenating display strings is not an equivalent input. Any NULL argument yields NULL; incompatible canonical encodings raise TYPE_MISMATCH, and this fast fingerprint is not a cryptographic authenticator.

Example

hash_city_64('sensor', 7) = hash_city_64('sensor', 7)
-- → true

hash_crc32

Computes a 32-bit cyclic redundancy checksum for binary or UTF-8 input.

hash_crc32(bytes|string) -> uint32
Kindscalar
Signature classscalar/unary
Returnsuint32
Aliasescrc32
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Applies the CRC-32 checksum to the supplied bytes, interpreting a string as UTF-8. NULL produces NULL and empty input produces zero. The checksum detects common transmission damage rather than providing cryptographic collision resistance; incompatible argument types raise TYPE_MISMATCH.

Example

hash_crc32('123456789')
-- → 3421780262

hash_farm_64

Maps a sequence of typed arguments to the pinned FarmHash64 result.

hash_farm_64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasesfarm_hash64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Feeds canonical value encodings into the selected FarmHash64 implementation variant. The variant is part of the compatibility contract rather than being selected opportunistically by hardware. NULL in the argument list propagates; TYPE_MISMATCH rejects values without an admitted encoding, and collisions remain possible.

Example

hash_farm_64('reading', 12) = hash_farm_64('reading', 12)
-- → true

hash_farm_fingerprint64

Produces a portable FarmHash fingerprint from canonically encoded arguments.

hash_farm_fingerprint64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasesfarm_fingerprint64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Uses the stable Fingerprint64 operation over typed arguments and their boundaries. Its output is an unsigned integer intended for repeatable partitioning or comparisons, not for proving authenticity. A NULL argument produces NULL, and incompatible value encodings raise TYPE_MISMATCH.

Example

hash_farm_fingerprint64('product', 3) = hash_farm_fingerprint64('product', 3)
-- → true

hash_hive

Calculates the Hive-compatible signed checksum of a string’s encoded contents.

hash_hive(string) -> int32
Kindscalar
Signature classscalar/unary
Returnsint32
Aliaseshive_hash
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Returns an int32 using the Hive string-hashing contract, including its byte signedness and wrapping rules. Interoperability is fixed by versioned byte-level vectors, so callers should not substitute the Java Unicode routine for arbitrary text. NULL returns NULL and nonstring input raises TYPE_MISMATCH.

Example

hash_hive('')
-- → 0

hash_hmac

Authenticates a message with a supplied key and a selected SHA-2 HMAC algorithm.

hash_hmac(string,bytes,bytes) -> bytes
hash_hmac(string,string,string) -> bytes
Kindscalar
Signature classscalar/ternary
Returnsbytes
Aliaseshmac
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Arguments are a constant algorithm name, key and message, with supported names sha256, sha384 and sha512. It returns raw authentication bytes and treats string keys and messages as UTF-8. NULL arguments yield NULL; unknown algorithms raise INVALID_ARGUMENT and incompatible key/message types raise TYPE_MISMATCH.

Example

length(hash_hmac('sha256', 'key', 'message'))
-- → 32

hash_int_32

Scrambles one integer into a compact unsigned 32-bit hash value.

hash_int_32(I) -> uint32
Kindscalar
Signature classscalar/unary
Returnsuint32
Aliasesint_hash32
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Applies the catalog’s pinned integer-only mixing function without treating the input as decimal text. The uint32 result may collide even when source integers are distinct. SQL NULL returns NULL and noninteger arguments raise TYPE_MISMATCH; this operation is intended for fast distribution rather than cryptographic protection.

Example

hash_int_32(42) = hash_int_32(42)
-- → true

hash_int_64

Derives an unsigned 64-bit mixing value directly from an integer.

hash_int_64(I) -> uint64
Kindscalar
Signature classscalar/unary
Returnsuint64
Aliasesint_hash64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Uses the versioned integer mixer to spread the input’s representation over a uint64 result. It does not promise reversibility or a collision-free mapping of wide integers. NULL propagates, incompatible noninteger types raise TYPE_MISMATCH, and repeated equal typed inputs produce the same result.

Example

hash_int_64(17) = hash_int_64(17)
-- → true

hash_java

Reproduces Java string hash codes using UTF-16 code units and wrapped signed arithmetic.

hash_java(string) -> int32
Kindscalar
Signature classscalar/unary
Returnsint32
Aliasesjava_hash
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Accumulates UTF-16 code units with the Java polynomial multiplier 31 and 32-bit wraparound. The returned int32 can be negative; supplementary Unicode characters contribute a surrogate pair. NULL yields NULL, empty text hashes to zero, and a nonstring argument raises TYPE_MISMATCH.

Example

hash_java('abc')
-- → 96354

hash_keccak256

Returns the Keccak-256 digest, using the pre-standardization padding convention.

hash_keccak256(bytes|string) -> fixed_string(32)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(32)
Aliaseskeccak256
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Generates thirty-two raw digest bytes in fixed_string(32) from binary or UTF-8 input. Keccak padding distinguishes this function from SHA3-256, so the algorithms are not interchangeable. SQL NULL propagates and incompatible message types raise TYPE_MISMATCH; no hexadecimal rendering is implicit.

Example

length(hash_keccak256('abc'))
-- → 32

hash_md5

Returns the sixteen raw MD5 digest bytes for a string or binary message.

hash_md5(bytes|string) -> fixed_string(16)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(16)
Aliasesmd5
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Hashes bytes directly and hashes strings through their UTF-8 representation. The fixed_string(16) result is binary, including for the empty message, rather than thirty-two hexadecimal characters. NULL remains NULL and a wrong argument type raises TYPE_MISMATCH; MD5 is retained for compatibility without a collision-resistance claim.

Example

hex_encode(hash_md5('abc'))
-- → '900150983CD24FB0D6963F7D28E17F72'

hash_murmur_2_32

Calculates MurmurHash2’s 32-bit variant over a structured value sequence.

hash_murmur_2_32(T,...) -> uint32
Kindscalar
Signature classscalar/variadic+generic
Returnsuint32
Aliasesmurmur_hash2_32
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Encodes each argument with its logical type before applying the pinned 32-bit MurmurHash2 routine. Result bits are returned as uint32, avoiding interpretation as a signed application identifier. Any SQL NULL returns NULL; incompatible encodings raise TYPE_MISMATCH and the algorithm offers no cryptographic guarantee.

Example

hash_murmur_2_32('order', 5) = hash_murmur_2_32('order', 5)
-- → true

hash_murmur_2_64

Returns the wide MurmurHash2 fingerprint for canonical typed inputs.

hash_murmur_2_64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasesmurmur_hash2_64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Applies the specified 64-bit MurmurHash2 variant to the ordered argument encoding. Reordering arguments or changing their logical descriptors can change the resulting uint64. NULL propagates through the whole call; TYPE_MISMATCH rejects unencodable input, and fingerprint equality does not establish value equality.

Example

hash_murmur_2_64('temperature', 20) = hash_murmur_2_64('temperature', 20)
-- → true

hash_murmur_3_128

Generates sixteen raw fingerprint bytes using MurmurHash3 over typed values.

hash_murmur_3_128(T,...) -> fixed_string(16)
Kindscalar
Signature classscalar/variadic+generic
Returnsfixed_string(16)
Aliasesmurmur_hash3_128
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Returns the 128-bit MurmurHash3 result as fixed_string(16), not as hexadecimal display text. The argument order and logical descriptors are part of the hashed representation. NULL propagates, incompatible types raise TYPE_MISMATCH, and callers needing readable digits must explicitly encode the raw output.

Example

length(hash_murmur_3_128('reading', 4))
-- → 16

hash_murmur_3_32

Compresses canonically serialized arguments with the 32-bit MurmurHash3 algorithm.

hash_murmur_3_32(T,...) -> uint32
Kindscalar
Signature classscalar/variadic+generic
Returnsuint32
Aliasesmurmur_hash3_32
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Produces the uint32 MurmurHash3 variant from argument values together with their type boundaries. This is a deterministic distribution hash whose variant and seed belong to the catalog contract. A NULL input yields NULL, and incompatible types raise TYPE_MISMATCH instead of falling back to string formatting.

Example

hash_murmur_3_32('humidity', 60) = hash_murmur_3_32('humidity', 60)
-- → true

hash_murmur_3_64

Computes a 64-bit MurmurHash3 result from the ordered argument encoding.

hash_murmur_3_64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasesmurmur_hash3_64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Uses the catalog’s fixed MurmurHash3 64-bit compatibility routine and returns uint64. Typed encoding keeps argument boundaries explicit and supports stable repeated evaluation. SQL NULL in any position returns NULL; inadmissible encodings raise TYPE_MISMATCH, and the result is not a cryptographic digest.

Example

hash_murmur_3_64('pressure', 1000) = hash_murmur_3_64('pressure', 1000)
-- → true

hash_sha1

Builds a twenty-byte SHA-1 compatibility digest from message bytes.

hash_sha1(bytes|string) -> fixed_string(20)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(20)
Aliasessha1
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Produces SHA-1 output in fixed_string(20), using UTF-8 when the message is supplied as a string. Empty input has its normal digest and must not be confused with SQL NULL, which propagates. Incompatible message types raise TYPE_MISMATCH; the raw result requires explicit encoding for a hexadecimal display.

Example

hex_encode(hash_sha1('abc'))
-- → 'A9993E364706816ABA3E25717850C26C9CD0D89D'

hash_sha224

Derives the SHA-224 digest as twenty-eight binary bytes.

hash_sha224(bytes|string) -> fixed_string(28)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(28)
Aliasessha224
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Applies SHA-224 to the complete input byte sequence and returns fixed_string(28). Text is interpreted as UTF-8 without normalization, so canonically equivalent Unicode spellings may hash differently. SQL NULL produces NULL and incompatible logical types raise TYPE_MISMATCH; encoding the digest for display is explicit.

Example

length(hash_sha224('abc'))
-- → 28

hash_sha256

Returns a 256-bit SHA-2 digest of binary data or UTF-8 text.

hash_sha256(bytes|string) -> fixed_string(32)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(32)
Aliasessha256
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Computes SHA-256 over the supplied bytes and exposes all thirty-two digest bytes in fixed_string(32). No text normalization or implicit hexadecimal formatting is performed. A NULL message yields NULL, while incompatible argument types raise TYPE_MISMATCH; the empty message is a valid hash input.

Example

hex_encode(hash_sha256('abc'))
-- → 'BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD'

hash_sha384

Calculates SHA-384 and exposes its forty-eight-byte binary digest.

hash_sha384(bytes|string) -> fixed_string(48)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(48)
Aliasessha384
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Uses the SHA-384 initialization and compression rules over bytes or a string’s UTF-8 encoding. The result retains every output byte, including zero bytes, in fixed_string(48). NULL propagates and other input types raise TYPE_MISMATCH; a readable hexadecimal representation would contain ninety-six digits.

Example

length(hash_sha384('abc'))
-- → 48

hash_sha512

Hashes a message with SHA-512 to obtain sixty-four raw bytes.

hash_sha512(bytes|string) -> fixed_string(64)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(64)
Aliasessha512
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Consumes the exact byte message, or UTF-8 text bytes, and returns fixed_string(64). The output is the complete SHA-512 digest rather than a shortened checksum. SQL NULL returns NULL; incompatible types raise TYPE_MISMATCH, and callers must choose an explicit representation when exporting the binary result.

Example

length(hash_sha512('abc'))
-- → 64

hash_sha512_256

Computes the distinct SHA-512/256 construction for a thirty-two-byte result.

hash_sha512_256(bytes|string) -> fixed_string(32)
Kindscalar
Signature classscalar/unary
Returnsfixed_string(32)
Aliasessha512_256
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Applies the specified SHA-512/256 initialization values and returns fixed_string(32). This is not equivalent to truncating an ordinary SHA-512 digest, even though both use related compression machinery. NULL remains NULL and incompatible message types raise TYPE_MISMATCH; strings contribute their unnormalized UTF-8 bytes.

Example

length(hash_sha512_256('abc'))
-- → 32

hash_sip_128

Emits a sixteen-byte SipHash result for a sequence of structured arguments.

hash_sip_128(T,...) -> fixed_string(16)
Kindscalar
Signature classscalar/variadic+generic
Returnsfixed_string(16)
Aliasessip_hash128, sipHash128
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

The pinned 128-bit variant hashes canonical typed inputs and returns fixed_string(16). Byte layout and variant are fixed by compatibility vectors rather than inferred from host integer endianness. NULL arguments produce NULL; incompatible encodings raise TYPE_MISMATCH, and display formatting is a separate operation.

Example

length(hash_sip_128('sensor', 2))
-- → 16

hash_sip_64

Evaluates fixed-seed SipHash over one or more canonical SQL values.

hash_sip_64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasessip_hash64, sipHash64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Produces uint64 with the SQL function’s documented fixed seed and compatibility variant. The seed is not a user secret, so the output must not be used as an authentication tag. Every NULL argument yields NULL, while incompatible typed encodings raise TYPE_MISMATCH.

Example

hash_sip_64('sample', 6) = hash_sip_64('sample', 6)
-- → true

hash_xx_32

Creates a compact xxHash32 fingerprint from typed arguments.

hash_xx_32(T,...) -> uint32
Kindscalar
Signature classscalar/variadic+generic
Returnsuint32
Aliasesxx_hash32, xxHash32
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Processes the canonical serialization with the fixed xxHash32 algorithm and returns uint32. This fast checksum can support partition selection but does not make unequal values collision-free. NULL in any argument returns NULL, and unencodable types raise TYPE_MISMATCH.

Example

hash_xx_32('item', 9) = hash_xx_32('item', 9)
-- → true

hash_xx_64

Computes the classic xxHash64 checksum over canonical value encodings.

hash_xx_64(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasesxx_hash64, xxHash64
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Returns a uint64 using the classic 64-bit xxHash routine, with argument boundaries preserved by serialization. The operation is deterministic but deliberately noncryptographic. SQL NULL propagates; an incompatible descriptor raises TYPE_MISMATCH instead of being hashed through locale-dependent text.

Example

hash_xx_64('batch', 8) = hash_xx_64('batch', 8)
-- → true

hash_xxh3

Fingerprints typed SQL values with the newer 64-bit XXH3 algorithm.

hash_xxh3(T,...) -> uint64
Kindscalar
Signature classscalar/variadic+generic
Returnsuint64
Aliasesxxh3
StreamingContinuous — evaluated per row with no retained state.
DeterminismDeterministic — the same arguments always give the same result.
NULL handlingAny NULL argument gives NULL.

Uses the pinned XXH3 64-bit routine rather than the classic xxHash64 algorithm. It hashes the canonical argument stream, so its result is repeatable for identical typed values but may differ from other xxHash variants. NULL returns NULL and unencodable arguments raise TYPE_MISMATCH; no cryptographic resistance is claimed.

Example

hash_xxh3('reading', 11) = hash_xxh3('reading', 11)
-- → true

On this page