久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Sqoop+Hive+MySQL怎么配置用戶某時(shí)間范圍

共計(jì) 2340 個(gè)字符,預(yù)計(jì)需要花費(fèi) 6 分鐘才能閱讀完成。

這篇文章主要講解了“Sqoop+Hive+MySQL 怎么配置用戶某時(shí)間范圍”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著丸趣 TV 小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“Sqoop+Hive+MySQL 怎么配置用戶某時(shí)間范圍”吧!

一、創(chuàng)建配置文件
【1、創(chuàng)建 table_env 文件,增加如下內(nèi)容】
執(zhí)行命令:vi table_env
內(nèi)容:

此處)折疊或打開(kāi)

insert overwrite directory ${hivevar:hdfs_path} ROW FORMAT DELIMITED FIELDS TERMINATED BY ${hivevar:field_term} select * from (select c.area,p.product_name,

 sum(rn) visit_num,

 row_number()over(partition by c.area order by sum(rn) desc) rn,

  ${hivevar:action_time} action_time

 from city_info c join (

 select product_id,city_id,count(1) rn from user_click where action_time= ${hivevar:action_time} group by product_id,city_id

 ) u join product_info p

 on c.city_id = case when u.city_id is null then concat(cityid ,rand()) else u.city_id end

 and p.product_id = case when u.product_id is null then concat(prodid ,rand()) else u.product_id end

 group by c.area,p.product_name) a

where a.rn

退出保存(:wq)

【3、創(chuàng)建從 Hive 導(dǎo)出腳本:創(chuàng)建 hive_to_mysql.sh 文件,增加如下內(nèi)容】
執(zhí)行命令:vi hive_to_mysql.sh
內(nèi)容:

此處)折疊或打開(kāi)

create database works DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

1.2、創(chuàng)建表

點(diǎn)擊 (此處) 折疊或打開(kāi)

– 城市表

create table city_info(

city_id int,

city_name varchar(255),

area varchar(255)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

– 產(chǎn)品表

create table product_info(

product_id int,

product_name varchar(50),

extend_info varchar(100)

)ENGINE=InnoDB DEFAULT CHARSET=utf8;

— 用戶點(diǎn)擊表

create table user_click(

user_id int,

session_id varchar(50),

action_time varchar(30),

city_id int(11),

product_id int(11)

)ENGINE=InnoDB DEFAULT CHARSET=utf8;

– 統(tǒng)考結(jié)果表

create table user_click_rs(

area varchar(50),

product_name varchar(50),

visit_num int(11),

rn int(11),

sdate varchar(10)

)ENGINE=InnoDB DEFAULT CHARSET=utf8;

【2、Hive 信息】
創(chuàng)建 HIve 表

點(diǎn)擊 (此處) 折疊或打開(kāi)

– 用戶點(diǎn)擊表

create external table user_click(

user_id string,

session_id string,

city_id string,

product_id string

)

partitioned by (action_time string)

ROW FORMAT DELIMITED FIELDS TERMINATED BY \t

location /works/user_click

– 用戶點(diǎn)擊臨時(shí)表

create external table tmp_user_click(

user_id string,

session_id string,

action_time string,

city_id string,

product_id string

)

ROW FORMAT DELIMITED FIELDS TERMINATED BY \t

location /works/tmp_user_click

– 城市表

create external table city_info(

city_id int,

city_name string,

area string

)

ROW FORMAT DELIMITED FIELDS TERMINATED BY \t

location /works/city_info

– 產(chǎn)品表

create external table product_info(

product_id int,

product_name string,

extend_info string

)

ROW FORMAT DELIMITED FIELDS TERMINATED BY \t

location /works/product_info

感謝各位的閱讀,以上就是“Sqoop+Hive+MySQL 怎么配置用戶某時(shí)間范圍”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì) Sqoop+Hive+MySQL 怎么配置用戶某時(shí)間范圍這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-15發(fā)表,共計(jì)2340字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒(méi)有評(píng)論)
主站蜘蛛池模板: 肥乡县| 类乌齐县| 富宁县| 崇明县| 金乡县| 微博| 合水县| 大化| 台山市| 田林县| 封丘县| 通榆县| 玉山县| 龙泉市| 马鞍山市| 丹凤县| 水城县| 大方县| 天祝| 哈巴河县| 涿鹿县| 花莲市| 和顺县| 文水县| 伽师县| 保山市| 历史| 盐边县| 遂平县| 城固县| 桐城市| 浦城县| 谢通门县| 张家港市| 五家渠市| 扶绥县| 西充县| 诸城市| 会同县| 铅山县| 达尔|