COMPRESSION_CODEC Query Option (Impala 2.0 or higher only)

When Impala writes Parquet data files using the INSERT statement, the underlying compression is controlled by the COMPRESSION_CODEC query option.

Note: Prior to Impala 2.0, this option was named PARQUET_COMPRESSION_CODEC. In Impala 2.0 and later, the PARQUET_COMPRESSION_CODEC name is not recognized. Use the more general name COMPRESSION_CODEC for new code.

Syntax:

  1. SET COMPRESSION_CODEC=codec_name;

The allowed values for this query option are SNAPPY (the default), GZIP, and NONE.

Note: A Parquet file created with COMPRESSION_CODEC=NONE is still typically smaller than the original data, due to encoding schemes such as run-length encoding and dictionary encoding that are applied separately from compression.

The option value is not case-sensitive.

If the option is set to an unrecognized value, all kinds of queries will fail due to the invalid option setting, not just queries involving Parquet tables. (The value BZIP2 is also recognized, but is not compatible with Parquet tables.)

Type: STRING

Default: SNAPPY

Examples:

  1. set compression_codec=gzip;
  2. insert into parquet_table_highly_compressed select * from t1;
  3. set compression_codec=snappy;
  4. insert into parquet_table_compression_plus_fast_queries select * from t1;
  5. set compression_codec=none;
  6. insert into parquet_table_no_compression select * from t1;
  7. set compression_codec=foo;
  8. select * from t1 limit 5;
  9. ERROR: Invalid compression codec: foo

Related information:

For information about how compressing Parquet data files affects query performance, see Snappy and GZip Compression for Parquet Data Files.

Parent topic: Query Options for the SET Statement