Syntax:
parse_binary(string, encoding)
Creates a binary
from an string encoded in encoding
format.
Arguments:
string
: an encoded string
,encoding
: a string notation specifies the encoding type of the given string
. Currently we support hex
and base64
format.Return Value:
binary
that is decoded from the given string
,missing
if any argument is a missing
value,null
if any argument is a null
value but no argument is a missing
value,Example:
[ parse_binary("ABCDEF0123456789","hex"), parse_binary("abcdef0123456789","HEX"), parse_binary('QXN0ZXJpeAE=',"base64") ];
The expected result is:
[ hex("ABCDEF0123456789"), hex("ABCDEF0123456789"), hex("4173746572697801") ]
Syntax:
print_binary(binary, encoding)
Prints a binary
to the required encoding string
format.
Arguments:
binary
: a binary
data need to be printed.encoding
: a string notation specifies the expected encoding type. Currently we support hex
and base64
format.Return Value:
string
that represents the encoded format of a binary
,missing
if any argument is a missing
value,null
if any argument is a null
value but no argument is a missing
value,Example:
[ print_binary(hex("ABCDEF0123456789"), "base64"), print_binary(base64("q83vASNFZ4k="), "hex") ]
The expected result are:
[ "q83vASNFZ4k=", "ABCDEF0123456789" ]
Syntax:
binary_length(binary)
Returns the number of bytes storing the binary data.
Arguments:
binary
: a binary
value to be checked.Return Value:
bigint
that represents the number of bytes,missing
if the argument is a missing
value,null
if the argument is a null
value,Example:
binary_length(hex("00AA"))
The expected result is:
2
Syntax:
sub_binary(binary, offset[, length])
Returns the sub binary from the given binary
based on the given start offset with the optional length
.
Arguments:
binary
: a binary
to be extracted,offset
: a tinyint
, smallint
, integer
, or bigint
value as the starting offset of the sub binary in binary
(starting at 0),length
: (Optional) a tinyint
, smallint
, integer
, or bigint
value as the length of the sub binary.Return Value:
binary
that represents the sub binary,missing
if any argument is a missing
value,null
if any argument is a null
value but no argument is a missing
value,Example:
sub_binary(hex("AABBCCDD"), 4);
The expected result is
hex("DD")
Syntax:
binary_concat(array)
Concatenates a binary array
or multiset
into a single binary.
Arguments:
array
: an array
or multiset
of binaries (could be null
or missing
) to be concatenated.Return Value :
binary
value,missing
if the argument is a missing
value,null
if the argument is a null
value,missing
if any element in the input array is missing
,null
if any element in the input array is null
but no element in the input array is missing
,Example:
binary_concat([hex("42"), hex(""), hex('42')]);
The expected result is
hex("4242")