0

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 ?

Beyhan Gul
  • 1,191
  • 1
  • 15
  • 25

1 Answers1

3

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

Shalaj
  • 579
  • 8
  • 19
  • so after that all tables will be zip ? should i write it always before insert any table ? – Beyhan Gul Apr 12 '17 at 12:39
  • all data files will be compressed in gz , you need to set these properties once per session , if you exit the session and again start new session set them again before insert data into backup table – Shalaj Apr 12 '17 at 12:42
  • last question is should i insert data in hive or also can insert via impala ? and could you add a link below your answer about that question.thanks for reply – Beyhan Gul Apr 12 '17 at 12:48
  • yes you can insert data via impala also , i didn't get the last part of your comment – Shalaj Apr 12 '17 at 13:04
  • but session was opened on hive ? how can hdfs knows it ? – Beyhan Gul Apr 12 '17 at 13:10
  • if you are using hive CLI, till the time you dont exit session remain open , once you exit session will close, if you are executing query using some script, till the time script is executing session remain open – Shalaj Apr 12 '17 at 13:13