You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
createtablebuyer_log(id string,buyer_id string,dt string,ip string,opt_type string)
row format delimited fields terminated by '\t' stored as textfile;
createtablebuyer_favorite(buyer_id string,goods_id string,dt string)
row format delimited fields terminated by '\t' stored as textfile;
load data local inpath '/home/hadoop/buyer_log' into table buyer_log;
load data local inpath '/home/hadoop/buyer_favorite' into table buyer_favorite;
4.常规操作
select*from buyer_log limit2;
select*from buyer_favorite limit2;
selectb.buyer_idfrom buyer_log b whereb.opt_type=1limit2;
selectb.buyer_idfrom buyer_log b whereb.opt_type=1limit3;
selectl.dt,f.goods_idfrom buyer_log l,buyer_favorite f wherel.buyer_id=f.buyer_idlimit5;
create table goods_visit(goods_id string,click_num int)
row format delimited fields terminated by '\t' stored as textfile;
load data local inpath'/home/hadoop/goods_visit' into table goods_visit;
create table order_items(item_id string,order_id string,goods_id string,goods_number string,
shop_price string,goods_price string,goods_amount string)
row format delimited fields terminated by '\t' stored as textfile;
load data local inpath '/home/hadoop/order_items' into table order_items;
10.Order by, Sort by, Group by, Distribute by, Cluster by
select* from goods_visit order by click_num desc limit 4;set mapred.reduce.tasks=3;select* from order_items sort by goods_id;selectdt,count(buyer_id) from buyer_favorite group by dt;set mapred.reduce.tasks=3;
insert overwrite local directory '/tmp/out3'select* from buyer_favorite distribute by buyer_id;set mapred.reduce.tasks=3;select* from buyer_favorite cluster by buyer_id;