load csv file of gzip file into hive

2019-07-31 05:35发布

问题:

I had a file which is the format of gzip consisting of csv file;I want to load the data into hive ? how can i do ?I create table with textfile and load in ,but cannot work ,Also set coedc ,buit also not work

回答1:

Make sure your file ends with .gz


Demo

(Done on a local file system)

bash

bash$ cat | gzip - >mytable/mydata.gz~
1
2
3

hive

create external table mytable (i int);

select * from mytable;

+--------+
|   i    |
+--------+
| (null) |
+--------+

bash

bash$ mv mytable/mydata.gz~ mytable/mydata.gz

hive

select * from mytable;

+---+
| i |
+---+
| 1 |
| 2 |
| 3 |
+---+