- Categories:
String & binary functions (Compression/Decompression)
DECOMPRESS_ BINARY¶
Decompresses the compressed BINARY input parameter.
- See also:
Syntax¶
Arguments¶
Required:
inputA
BINARYvalue (or expression) with data that was compressed using one of the compression methods specified in COMPRESS.If you attempt to decompress a compressed string, rather than a compressed
BINARYvalue, you do not get an error; instead, the function returns aBINARYvalue. See the Usage Notes below for details.methodThe compression method originally used to compress the
input. See COMPRESS for a list of compression methods.The
DECOMPRESS_BINARYmethod, unlike theCOMPRESSmethod, does not require you to specify the compression level. If you do specify the compression level,DECOMPRESS_BINARYignores it and uses the actual compression level.
Returns¶
The data type of the returned value is BINARY.
Usage notes¶
- If the compression method is unknown or invalid, the query fails.
- The compression method name (e.g.
ZLIB) is case-insensitive. - The
DECOMPRESS_BINARYfunction can decompress data that was originally in string format. However, the output ofDECOMPRESS_BINARYis stillBINARY, not string. For example,SELECT DECOMPRESS_BINARY(COMPRESS('Hello', 'SNAPPY), 'SNAPPY')returns aBINARYvalue; if you display that value, it is shown as48656C6C6F, which is the hexadecimal representation of ‘Hello’. To avoid confusion, Snowflake recommends decompressing string data by using DECOMPRESS_STRING rather thanDECOMPRESS_BINARY.
Returns¶
A BINARY value with decompressed data.
Examples¶
This shows a simple example of decompressing BINARY data that contains
a compressed value.