导入的意外元素将压缩数据导入Hive

时间:2017-06-14 14:43:31

标签: hadoop hive hiveql

我正在尝试将压缩的TXT文件加载到Hive中。操作结束时没有任何错误,但是在构造的表中,开头有一些意外的字符。为什么会这样? 有关Hive中压缩数据存储的更多信息:https://cwiki.apache.org/confluence/display/Hive/CompressedStorage

# cat test.txt
        tab1    tab2    tab3
        tab4    tab5    tab6
        tab7    tab8    tab9

# tar -cvzf test.gz test.txt
test.txt

# cat hiveQuery.hql
CREATE TABLE raw (col1 STRING,col2 STRING,col3 STRING)
   ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
;
LOAD DATA LOCAL INPATH '/test.gz' INTO TABLE raw;

#  hive -f hiveQuery.hql
WARNING: Use "yarn jar" to launch YARN applications.

Logging initialized using configuration in file:/etc/hive/2.4.0.0-169/0/hive-log4j.properties
OK
Time taken: 6.936 seconds
Loading data to table default.raw
Table default.raw stats: [numFiles=1, totalSize=145]
OK

# hive -e "select * from raw"
WARNING: Use "yarn jar" to launch YARN applications.

Logging initialized using configuration in file:/etc/hive/2.4.0.0-169/0/hive-log4j.properties
OK
test.txt                                                                  0000644 0000000 0000000 00000000055 13120243734 011273  0                 ustar   root                            root                              tab1    tab2    tab3
tab4    tab5    tab6
tab7    tab8    tab9
                                                                          NULL    NULL

1 个答案:

答案 0 :(得分:1)

tar格式包含其他标题信息 使用gzip压缩文件,看看它是否正常。