Search code examples
hadoopmapreducehdfsimpalahadoop-partitioning

Create zip tables in HDFS


I have tried to create table whic is not zip like this.

CREATE TABLE example_table (|   a BIGINT,    b BIGINT,    v STRING,   d TINYINT   )  STORED AS TEXTFILE  LOCATION /path/to/directory/

It's not zip table. I want to also create new table with zip to take history of this table. How can i create just 1 table with zip ?


Solution

  • First set below properties

    SET hive.exec.compress.output=true;
    SET mapred.output.compression.type=BLOCK;
    set mapred.output.compress=true;
    set mapred.output.compression.codec=org.apache.hadoop.io.compress.GzipCodec;
    

    Now insert data into backup table

    INSERT INTO backup_table select * from example_table
    

    Now data will convert into Gzip format