You need to enable JavaScript to run this app.
ByteHouse Cloud Data Warehouse Version

ByteHouse Cloud Data Warehouse Version

Copy page
Download PDF
Function reference
Encoding functions
Copy page
Download PDF
Encoding functions

UUIDNumToString

Accepts a FixedString(16) value and returns a string in text format containing 36 characters.
Syntax

UUIDNumToString(FixedString(16))

Parameter

  • A FixedString(16) value

Return value

  • String.

Example

SELECT'a/<@];!~p{jTj={)' AS bytes, 
    UUIDNumToString(toFixedString(bytes, 16)) AS uuid
┌─bytes────────────┬─uuid─────────────────────────────────┐ 
│ a/<@];!~p{jTj={) │ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ 
└──────────────────┴──────────────────────────────────────┘

UUIDStringToNum

Accepts a string in the format containing 36 characters xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and returns it as a group of bytes in FixedString(16).
Syntax

UUIDStringToNum(String)

Parameter

  • UUID format string

Return value

  • FixedString(16)

Example

SELECT'612f3c40-5d3b-217e-707b-6a546a3d7b29' AS uuid, 
    UUIDStringToNum(uuid) AS bytes
┌─uuid─────────────────────────────────┬─bytes────────────┐ 
│ 612f3c40-5d3b-217e-707b-6a546a3d7b29 │ a/<@];!~p{jTj={) │ 
└──────────────────────────────────────┴──────────────────┘

bitmaskToArray

Accepts an integer. Returns a UInt64 number array containing a list of powers of 2 whose sum equals the source number. The numbers in the array are arranged in ascending order.
Syntax

bitmaskToArray(num)

Parameter

  • num – an integer

Return value

  • A UInt64 number array containing a list of powers of 2 whose sum equals the source number.

Example

SELECT bitmaskToArray(1), bitmaskToArray(3), bitmaskToArray(4)
┌─bitmaskToArray(1)─┬─bitmaskToArray(3)─┬─bitmaskToArray(4)─┐ 
│ [1]               │ [1, 2]            │ [4]               │ 
└───────────────────┴───────────────────┴───────────────────┘

1 = power(2,0)
3 = power(2,0) + power(2,1)
4 = power(2,2)

bitmaskToList

Accepts an integer. Returns a string containing a list of powers of 2 whose sum equals the source number. The values are separated by commas in text format with no spaces and are arranged in ascending order.
Syntax

bitmaskToList(num)

Parameter

  • num – an integer

Return value

  • A string containing a list of powers of 2 whose sum equals the source number.

Example

SELECT bitmaskToList(1), bitmaskToList(3), bitmaskToList(4)
┌─bitmaskToList(1)─┬─bitmaskToList(3)─┬─bitmaskToList(4)─┐ 
│ 1                │ 1,2              │ 4                │ 
└──────────────────┴──────────────────┴──────────────────┘

1 = power(2,0)
3 = power(2,0) + power(2,1)
4 = power(2,2)

hex

Returns a string containing the hexadecimal representation of the parameter.
Syntax

hex(arg)

This function uses uppercase letters A-F, and does not use any prefix (such as 0x) or suffix (such as h).
For integer parameters, it prints hexadecimal digits ("nibbles") from the most significant to the least significant (big-endian or "human-readable" order). It starts from the most significant non-zero byte (omitting leading zero bytes), but always prints two digits for each byte, even if the leading digit is zero.
Date and values of type DateTime are formatted as the corresponding integer (Date is the total number of days since the epoch, DateTime is the value of the Unix timestamp).
For String and FixedString, all bytes are simply encoded as two hexadecimal digits. Zero bytes are not omitted.

Last updated: 2026.03.31 16:13:53