All Products
Search
Document Center

MaxCompute:COMPRESS

Last Updated:Jul 24, 2023

Uses the GZIP algorithm to compress str or bin.

Syntax

binary compress(string <str>)
binary compress(binary <bin>)

Parameters

  • str: required. A value of the STRING type.

  • bin: required. A value of the BINARY type.

Return value

A value of the BINARY type is returned. If the input parameter is set to null, null is returned.

Examples

  • Example 1: Use the GZIP algorithm to compress string hello. Sample statement:

    -- The return value is =1F=8B=08=00=00=00=00=00=00=03=CBH=CD=C9=C9=07=00=86=A6=106=05=00=00=00. 
    select compress('hello');
  • Example 2: The input parameter is empty. Sample statement:

    -- The return value is =1F=8B=08=00=00=00=00=00=00=03=03=00=00=00=00=00=00=00=00=00. 
    select compress('');
  • Example 3: The input parameter is set to null. Sample statement:

    -- The return value is null. 
    select compress(null);

Related functions

For more information, see Other functions.