You need to enable JavaScript to run this app.
ByteHouse Enterprise Edition

ByteHouse Enterprise Edition

Copy page
Download PDF
Recommend functions
Hash function
Copy page
Download PDF
Hash function

Hash functions can be used to irreversibly and pseudo-randomly shuffle elements.

halfMD5

Calculate the MD5 of a string. Then, acquire the first 8 bytes of the result and return them as UInt64 (big endian). This function is quite inefficient (5 million short strings/seconds/core). If you do not need to use MD5, use the ‘sipHash64’ function.

MD5

Calculates the MD5 of a String and returns the result in FixedString(16). If you only need a 128-bit hash and don't necessarily need to use MD5, use the ‘sipHash128’ function. If you want to get the same output as the md5sum program, use lower(hex(MD5(s))).

sipHash64

Calculates the SipHash of a String. Takes a String type parameter and returns UInt64. SipHash is an encryption hash function. Its processing performance is at least three times faster than MD5. For Details, see link: https://131002.net/siphash/

sipHash128

Calculates the SipHash of a String. Accepts a String Type Param and Returns FixedString(16). The difference and the sipHash64 function is that its final Result is 128 bits.

cityHash64

Calculates the CityHash64 of any Quantity of Strings or the Hash function of any Quantity of Other Types using a specific implementation. For Strings, use the CityHash algorithm. This is a fast, non-cryptographic hash function for Strings. For other types of params, use a specific implementation of the Hash function, which is a fast, non-cryptographic hash function. If multiple params are passed, CityHash is used to combine the Hash result of these params. For example, you can calculate the checksum of the entire table, the result of which depends on the order of the rows: SELECT sum(cityHash64(*)) FROM table.

intHash32

Calculate a 32-bit hash for any type of Integer. This is a relatively efficient, non-cryptographic Hash function.

intHash64

Calculate a 64-bit hash code from any type of Integer. It works faster compared with the intHash32 function.

SHA1、SHA224、SHA256

Calculates the SHA-1, SHA-224, or SHA-256 of a String, and returns the resulting byte set as FixedString(20), FixedString(28), or FixedString(32). This function is quite inefficient (SHA-1 is approximately 5 million short Strings/seconds/Core, and SHA-224 and SHA-256 are approximately 2.2 million short Strings/seconds/Core). We Suggest using these functions only when you have to use them and cannot change anything. Even in these cases, we still Suggest adopting the Method / way of pre-calculating the function when writing Data. Instead of calculating them in SELECT.

URLHash(url[,N])

A fast, non-cryptographic hash function used to normalize strings obtained from URLs. URLHash(s) - Calculates a hash from a string, ignoring trailing symbols if they exist: /, ? Or #. URLHash(s, N) - Calculates the hash value of a string to level N in the URL hierarchy, ignoring trailing symbols if they exist: /, ? Or #. The level of the URL is the same as in URLHierarchy. This function is used in Yandex.Metrica.

farmHash64

Calculates the FarmHash64 of a string. Accepts a String type param. Return UInt64. For More Details, please refer to the link: FarmHash64

javaHash

Calculate the JavaHash of the String. Accepts a String type param. Return Int32. For More Details, please refer to the link: JavaHash

hiveHash

Calculate the HiveHash of a String. Accepts a String type param. Back Int32. And is the same as JavaHash

metroHash64

Calculate the MetroHash of a String. Accepts a String type param. Back UInt64. For more Details, please refer to the link: MetroHash64

jumpConsistentHash

Calculate the UInt64's JumpConsistentHash. Accept params of UInt64 Type. Back Int32. For More Details, please see the link: JumpConsistentHash

murmurHash2_32,murmurHash2_64

Calculate the String's MurmurHash2. Accepts a String-type param. Returns UInt64 or UInt32. For more details, please refer to the link: MurmurHash2

murmurHash3_32,murmurHash3_64,murmurHash3_128

Calculates the MurmurHash3 of a String. Accepts a String-type param. Returns UInt64 or UInt32 or FixedString(16). For more details, please refer to the link: MurmurHash3

xxHash32,xxHash64

Calculate the xxHash of the String. Accepts a String Type Param. Back UInt64 or UInt32. For More Details, see link: xxHash

Last updated: 2026.03.31 11:49:59