CDH5.4.5運行多字符分割記錄

準備工做:oop

測試文件內容:cis_cust_imp_info測試

20131131|+|100010001001|+|BR01|+|2000.01
20131131|+|100010001002|+|BR01|+|2000.02
20131131|+|100010001003|+|BR02|+|2000.03utf-8

將測試文件放入HDFS:hadoop

sudo -u hdfs hdfs dfs -mkdir -p /ceb/cis_cust_imp_info
sudo -u hdfs hdfs dfs -chmod 777 /ceb/cis_cust_imp_info
hdfs dfs -put cis_cust_imp_info /ceb/cis_cust_imp_infoci

 

在Hive中輸入下面的命令:input

add jar /opt/cloudera/parcels/CDH/lib/hive/lib/hive-contrib-1.1.0-cdh5.4.5.jar;
add jar /root/ceb/HiveMultiDelimiter.jar;string

DROP TABLE IF EXISTS cis_cust_imp_info_ext;
CREATE EXTERNAL TABLE IF NOT EXISTS cis_cust_imp_info_ext(statistics_dt string,cust_id string,open_org_id string,assert9_bal string)
ROW FORMAT SERDE 'com.cloudera.hadoop.hive.contrib.serde2.alter.MultiDelimitSerDe' WITH SERDEPROPERTIES ('input.delimited'='\|\+\|','field.encoding'='utf-8')
LOCATION '/ceb/cis_cust_imp_info';it

select * from cis_cust_imp_info_ext;table

--hive:將多字符分割變成impala/phoenix能處理的txt
create table cis_cust_imp_info(cust_id string,statistics_dt string,assert9_bal double)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
insert overwrite table cis_cust_imp_info select cust_id, statistics_dt, assert9_bal from cis_cust_imp_info_ext;coding

相關文章
相關標籤/搜索