COMPRESS
functionsupportedCore SQL functionsCompresses the input string or binary value with a compression method.
Syntax
COMPRESS(<input>, <method>)
Parameters
| Name | Required | Description |
|---|---|---|
input | required | A BINARY or string value (or expression) to be compressed. |
method | required | A string with compression method and optional compression level. Supported methods are: SNAPPY. ZLIB. ZSTD. BZ2. The compression level is specified in parentheses, for example: zlib(1). The compression level is a non-negative integer. 0 means default level (same as omitting the compression level). The compression level is ignored if the method doesn’t support compression levels. |
Returns
A BINARY with compressed data.
Usage notes
- If the compression method is unknown or invalid, the query fails.
- The compression method name (e.g. ZLIB) is case-insensitive.
- Not all inputs are compressible. For very short or difficult-to-compress input values, the output value might be the same length as, or even slightly longer than, the input value.