Teradata Compression and Decompression Functions | Teradata Vantage - 17.10 - Teradata Compression and Decompression Functions - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

Teradata provides the following functions for compressing and uncompressing data. These functions are stored in the TD_SYSFNLIB system database.

Function Type UDF Name Description
Compress TransUnicodeToUTF8 Takes UNICODE character input and stores it in UTF-8 format.

This is useful when the characters are in the ASCII script (U+0000 to U+007F) because UTF-8 uses one byte to represent these characters and UNICODE (UTF-16) uses two bytes.

Decompress TransUTF8ToUnicode Takes the data previously compressed using the TransUnicodeToUTF8 function and converts it back to UNICODE.
Compress LZCOMP Compresses UNICODE character data using the Lempel-Ziv algorithm.
Decompress LZDECOMP Uncompresses UNICODE data that was compressed using LZCOMP.
Compress LZCOMP_L Compresses LATIN character data using the Lempel-Ziv algorithm.
Decompress LZDECOMP_L Uncompresses LATIN data that was compressed using LZCOMP_L.
Compress CAMSET Compresses UNICODE character data into partial byte (for example, 4-bit digits or 5-bit alphabetic letters), one byte, or two byte values using a proprietary Teradata algorithm.
Decompress DECAMSET Uncompresses the UNICODE character data that was compressed using CAMSET.
Compress CAMSET_L Compresses LATIN character data into partial byte (for example, 4-bit digits or 5-bit alphabetic letters), or one byte values using a proprietary Teradata algorithm.
Decompress DECAMSET_L Uncompresses the LATIN character data that was compressed using CAMSET_L.
Compress TD_LZ_COMPRESS Compresses any supported ALC data type or predefined type data using Lempel-Ziv coding.
Decompress TD_LZ_DECOMPRESS Uncompresses any supported ALC data type or predefined type data that was compressed using TZ_LZ_COMPRESS.
Compress TS_COMPRESS Compresses TIME and TIMESTAMP data.
Decompress TS_DECOMPRESS Uncompresses TIME and TIMESTAMP data that was compressed using TS_COMPRESS.
Compress JSON_COMPRESS Compresses JSON data.
Decompress JSON_DECOMPRESS Uncompresses the JSON data that was compressed using JSON_COMPRESS.

For more information about these functions, see Teradata Vantage™ - SQL Functions, Expressions, and Predicates, B035-1145.

If these functions do not provide optimal compression for your data, you may implement your own UDFs for use in compressing and uncompressing table columns. For more information, see Teradata Vantage™ - SQL External Routine Programming, B035-1147.

If you create custom ALC UDFs, make sure to test them thoroughly. If the compression or decompression algorithm fails, compressed data may not be recoverable, or may be corrupted.