Binary Functions¶
- crc32(binary) bigint¶
Computes the crc32 checksum of
binary.
- from_base64(string) varbinary¶
Decodes a Base64-encoded
stringback into its original binary form. This function is capable of handling both fully padded and non-padded Base64 encoded strings. Partially padded Base64 strings are not supported and will result in a “UserError” status being returned.Examples¶
Query with padded Base64 string: :: SELECT from_base64(‘SGVsbG8gV29ybGQ=’); – [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
Query with non-padded Base64 string: :: SELECT from_base64(‘SGVsbG8gV29ybGQ’); – [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
Query with partial-padded Base64 string: :: SELECT from_base64(‘SGVsbG8gV29ybGQgZm9yIHZlbG94IQ=’); – UserError: Base64::decode() - invalid input string: string length is not a multiple of 4.
In the above examples, both the fully padded and non-padded Base64 strings (‘SGVsbG8gV29ybGQ=’ and ‘SGVsbG8gV29ybGQ’) decode to the binary representation of the text ‘Hello World’. A partial-padded Base64 string ‘SGVsbG8gV29ybGQgZm9yIHZlbG94IQ=’ will result in a “UserError” status indicating the Base64 string is invalid.
- from_base64url(string) varbinary¶
Decodes
stringdata from the base64 encoded representation using the URL safe alphabet into a varbinary.
- from_big_endian_32(varbinary) integer¶
Decodes
integervalue from a 32-bit 2’s complement big endianbinary.
- from_big_endian_64(varbinary) bigint¶
Decodes
bigintvalue from a 64-bit 2’s complement big endianbinary.
- from_hex(string) varbinary¶
Decodes binary data from the hex encoded
string.
- from_ieee754_32(binary) real¶
Decodes the 32-bit big-endian
binaryin IEEE 754 single-precision floating-point format. Throws a user error if input size is shorter / longer than 32 bits.
- from_ieee754_64(binary) double¶
Decodes the 64-bit big-endian
binaryin IEEE 754 double-precision floating-point format. Throws a user error if input size is shorter / longer than 64 bits.
- hmac_md5(binary, key) varbinary¶
Computes the HMAC with md5 of
binarywith the givenkey.
- hmac_sha1(binary, key) varbinary¶
Computes the HMAC with sha1 of
binarywith the givenkey.
- hmac_sha256(binary, key) varbinary¶
Computes the HMAC with sha256 of
binarywith the givenkey.
- hmac_sha512(binary, key) varbinary¶
Computes the HMAC with sha512 of
binarywith the givenkey.
- length(binary) bigint¶
Returns the length of
binaryin bytes.
- lpad(binary, size, padbinary) varbinary
Left pads
binarytosizebytes withpadbinary. Ifsizeis less than the length ofbinary, the result is truncated tosizecharacters.sizemust not be negative andpadbinarymust be non-empty.sizehas a maximum value of 1 MiB. In the case ofsizebeing smaller than the length ofbinary,binarywill be truncated from the right to fit thesize.
- md5(binary) varbinary¶
Computes the md5 hash of
binary.
- rpad(binary, size, padbinary) varbinary
Right pads
binarytosizebytes withpadbinary. Ifsizeis less than the length ofbinary, the result is truncated tosizecharacters.sizemust not be negative andpadbinarymust be non-empty.sizehas a maximum value of 1 MiB. In the case ofsizebeing smaller than the length ofbinary,binarywill be truncated from the right to fit thesize.
- sha1(binary) varbinary¶
Computes the SHA-1 hash of
binary.
- sha256(binary) varbinary¶
Computes the SHA-256 hash of
binary.
- sha512(binary) varbinary¶
Computes the SHA-512 hash of
binary.
- spooky_hash_v2_32(binary) varbinary¶
Computes the SpookyHashV2 32-bit hash of
binary.
- spooky_hash_v2_64(binary) varbinary¶
Computes the 64-bit SpookyHashV2 hash of
binary.
- to_base64(binary) varchar¶
Encodes
binaryinto a base64 string representation.
- to_base64url(binary) varchar¶
Encodes
binaryinto a base64 string representation using the URL safe alphabet.- to_big_endian_32(integer) varbinary¶
Encodes
integerin a 32-bit 2’s complement big endian format.
- to_big_endian_64(bigint) varbinary¶
Encodes
bigintin a 64-bit 2’s complement big endian format.
- to_hex(binary) varchar¶
Encodes
binaryinto a hex string representation.
- to_ieee754_32(real) varbinary¶
Encodes
realin a 32-bit big-endian binary according to IEEE 754 single-precision floating-point format.
- to_ieee754_64(double) varbinary¶
Encodes
doublein a 64-bit big-endian binary according to IEEE 754 double-precision floating-point format.
- xxhash64(binary) varbinary¶
Computes the xxhash64 hash of
binary.
- xxhash64(binary, bigint) varbinary¶
Computes the xxhash64 hash of
binarywithbigintseed.