GUNZIP Function
Overview
The GUNZIP function decompresses gzip-compressed binary data. It accepts a BINARY type input (must be valid gzip-compressed data) and returns the decompressed BINARY data. It is commonly used to restore data compressed by the gzip function, or to decompress externally provided gzip-format data.
Syntax
gunzip(expr)
Parameters
expr: The input data to be decompressed with gzip, of type BINARY. The data must be in valid gzip-compressed format.
Returns
Returns a BINARY type value representing the original binary data after gzip decompression.
Examples
-
Compress with gzip and then decompress with gunzip to verify data integrity (round-trip):
-
Decompress compressed data and check the length:
-
When the input is NULL:
Notes
- The input parameter must be of BINARY type and must be valid gzip-compressed data. If the input data is not in valid gzip format, an error will be returned.
- When the input parameter is NULL, the result is NULL.
- The decompressed data is of BINARY type. To use it as a string, use
CAST(expr AS VARCHAR)for type conversion. - Use the
gzipfunction to compress data, and pair it withgunzipfor data compression and decompression. - gunzip is the inverse of gzip:
gunzip(gzip(data))returns the original data.
