1数据导入--------------
CREATE EXTERNAL TABLE wizad_mdm_dev_lmj_edition_20141120 (
cookie_id STRING,
guid STRING
) ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘,‘
LINES TERMINATED BY ‘\n‘
stored as textfile
LOCATION ‘/user/wizad/test/lmj/edition_compare/‘;
2join(只接受等值)后的结果入表------------------------------------
CREATE TABLE wizad_mdm_dev_lmj_edition_result as
select *
from wizad_mdm_dev_lmj_20141120 as w
JOIN wizad_mdm_main as a ON (a.rowkey = w.guid);
SET mapred.job.queue.name=queue3;
SET hbase.client.scanner.caching=5000;
SET hbase.zookeeper.quorum=datanode06,datanode07,datanode08;
SET zookeeper.znode.parent=/hbase;
set hbase.regionserver.lease.period=180000;
INSERT OVERWRITE LOCAL DIRECTORY ‘/home/wizad/lmj/‘
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,‘
select cookie_id,rowkey,fixeddim_map
from wizad_mdm_main_from_hbase as a JOIN wizad_mdm_dev_lmj_edition_20141120 as w
ON (w.guid = a.rowkey);
SET mapred.job.queue.name=queue3;
SET hbase.client.scanner.caching=5000;
SET hbase.zookeeper.quorum=datanode06,datanode07,datanode08;
SET zookeeper.znode.parent=/hbase;
set hbase.regionserver.lease.period=180000;
CREATE TABLE wizad_mdm_dev_lmj_edition_result as
select cookie_id,rowkey,fixeddim_map
from wizad_mdm_main_from_hbase as a JOIN wizad_mdm_dev_lmj_edition_20141120 as w
ON (w.guid = a.rowkey);
========================================
select count(*) from wizad_mdm_dev_lmj_edition_result;14638
create TABLE wizad_mdm_dev_lmj_edition_insterest as
select cookie_id,rowkey,fixeddim_key,fixeddim_value
from wizad_mdm_dev_lmj_edition_result
LATERAL VIEW explode(fixeddim_map) my_t1 AS fixeddim_key,fixeddim_value
WHERE (fixeddim_key like ‘interest%‘);
-----------------------------------------
select count(*) from wizad_mdm_dev_lmj_edition_insterest;15331
INSERT OVERWRITE table wizad_mdm_dev_lmj_edition_insterest
select cookie_id,rowkey,fixeddim_key,fixeddim_value
from wizad_mdm_dev_lmj_edition_result
LATERAL VIEW explode(fixeddim_map) my_t1 AS fixeddim_key,fixeddim_value
WHERE (fixeddim_key like ‘interest%‘);
全路径也不行。
INSERT OVERWRITE DIRECTORY ‘hdfs://namenode/user/wizad/tmp/interest2/‘
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,‘
select * from wizad_mdm_dev_lmj_edition_insterest
但导出到本地,可以指定列分隔符
INSERT OVERWRITE local DIRECTORY ‘/home/wizad/lmj/inserest2‘
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,‘
select * from wizad_mdm_dev_lmj_edition_insterest