7.1用户画像–数据开发的步骤
u 数据开发前置依赖
-需求确定 pv uv topn
-建模确定表结构 create table t1(pv int,uv int,topn string)
-实现方案确定
u 数据开发过程
-表落地
-写sql语句实现业务逻辑
-部署代码
-数据测试
-试运行与上线
在接下来的客户基本属性表开发中演示开发的流程。
7.2 用户画像开发–客户基本属性表
复制代码
–用户画像-客户基本属性模型表
create database if not exists gdm;
create table if not exists gdm.itcast_gdm_user_basic(
user_id string ,–用户ID
user_name string ,–用户登陆名
user_sex string ,–用户性别
user_birthday string ,–用户生日
user_age bigint ,–用户年龄
constellation string ,–用户星座
province string ,–省份
city string ,–城市
city_level string ,–城市等级
hex_mail string ,–邮箱
op_mail string ,–邮箱运营商
hex_phone string ,–手机号
fore_phone string ,–手机前3位
op_phone string ,–手机运营商
add_time timestamp ,–注册时间
login_ip string ,–登陆ip地址
login_source string ,–登陆来源
request_user string ,–邀请人
total_mark bigint ,–会员积分
used_mark bigint ,–已使用积分
level_name string ,–会员等级名称
blacklist bigint ,–用户黑名单
is_married bigint ,–婚姻状况
education string ,–学历
monthly_money double ,–收入
profession string ,–职业
sex_model bigint ,–性别模型
is_pregnant_woman bigint ,–是否孕妇
is_have_children bigint ,–是否有小孩
children_sex_rate double ,–孩子性别概率
children_age_rate double ,–孩子年龄概率
is_have_car bigint ,–是否有车
potential_car_user_rate double ,–潜在汽车用户概率
phone_brand string ,–使用手机品牌
phone_brand_level string ,–使用手机品牌档次
phone_cnt bigint ,–使用多少种不同的手机
change_phone_rate bigint ,–更换手机频率
majia_flag string ,–马甲标志
majie_account_cnt bigint ,–马甲账号数量
loyal_model bigint ,–用户忠诚度
shopping_type_model bigint ,–用户购物类型
figure_model bigint ,–身材
stature_model bigint ,–身高
dw_date timestamp
) partitioned by (dt string);
复制代码
该模型表其基本信息主要来源于用户表、用户调查表。有静态信息和动态信息、后面的一些是数据挖掘模型(数据挖掘模型比较多,逻辑比较复杂,在机器学习课程中给大家介绍)。
复制代码
#***************************
–客户基本属性模型表BDM层
create database if not exists bdm;
create external table if not exists bdm.itcast_bdm_user(
user_id string ,–用户ID
user_name string ,–用户登陆名
user_sex string ,–用户性别
user_birthday string ,–用户生日
user_age bigint ,–用户年龄
constellation string ,–用户星座
province string ,–省份
city string ,–城市
city_level string ,–城市等级
hex_mail string ,–邮箱
op_mail string ,–邮箱运营商
hex_phone string ,–手机号
fore_phone string ,–手机前3位
op_phone string ,–手机运营商
add_time string ,–注册时间
login_ip string ,–登陆ip地址
login_source string ,–登陆来源
request_user string ,–邀请人
total_mark bigint ,–会员积分
used_mark bigint ,–已使用积分
level_name string ,–会员等级名称
blacklist bigint ,–用户黑名单
is_married bigint ,–婚姻状况
education string ,–学历
monthly_money double ,–收入
profession string --职业
) partitioned by (dt string)
row format delimited fields terminated by ‘,’;
alter table itcast_bdm_user add partition (dt=‘2017-01-01’) location ‘/business/itcast_bdm_user/2017-01-01’;
–客户基本属性表FDM层
create database if not exists fdm;
create table if not exists fdm.itcast_fdm_user_wide(
user_id string ,–用户ID
user_name string ,–用户登陆名
user_sex string ,–用户性别
user_birthday string ,–用户生日
user_age bigint ,–用户年龄
constellation string ,–用户星座
province string ,–省份
city string ,–城市
city_level string ,–城市等级
hex_mail string ,–邮箱
op_mail string ,–邮箱运营商
hex_phone string ,–手机号
fore_phone string ,–手机前3位
op_phone string ,–手机运营商
add_time string ,–注册时间
login_ip string ,–登陆ip地址
login_source string ,–登陆来源
request_user string ,–邀请人
total_mark bigint ,–会员积分
used_mark bigint ,–已使用积分
level_name string ,–会员等级名称
blacklist bigint ,–用户黑名单
is_married bigint ,–婚姻状况
education string ,–学历
monthly_money double ,–收入
profession string ,–职业
dw_date timestamp
) partitioned by (dt string);
–加载数据
insert overwrite table fdm.itcast_fdm_user_wide partition(dt=‘2017-01-01’)
select
t.user_id,
t.user_name,
t.user_sex,
t.user_birthday,
t.user_age,
t.constellation,
t.province,
t.city,
t.city_level,
t.hex_mail,
t.op_mail,
t.hex_phone,
t.fore_phone,
t.op_phone,
t.add_time,
t.login_ip,
t.login_source,
t.request_user,
t.total_mark,
t.used_mark,
t.level_name,
t.blacklist,
t.is_married,
t.education,
t.monthly_money,
t.profession,
from_unixtime(unix_timestamp()) dw_date
from bdm.itcast_bdm_user t where dt=‘2017-01-01’;
–用户画像-客户基本属性模型表GDM层
create database if not exists gdm;
create table if not exists gdm.itcast_gdm_user_basic(
user_id string ,–用户ID
user_name string ,–用户登陆名
user_sex string ,–用户性别
user_birthday string ,–用户生日
user_age bigint ,–用户年龄
constellation string ,–用户星座
province string ,–省份
city string ,–城市
city_level string ,–城市等级
hex_mail string ,–邮箱
op_mail string ,–邮箱运营商
hex_phone string ,–手机号
fore_phone string ,–手机前3位
op_phone string ,–手机运营商
add_time string ,–注册时间
login_ip string ,–登陆ip地址
login_source string ,–登陆来源
request_user string ,–邀请人
total_mark bigint ,–会员积分
used_mark bigint ,–已使用积分
level_name string ,–会员等级名称
blacklist bigint ,–用户黑名单
is_married bigint ,–婚姻状况
education string ,–学历
monthly_money double ,–收入
profession string ,–职业
sex_model bigint ,–性别模型
is_pregnant_woman bigint ,–是否孕妇
is_have_children bigint ,–是否有小孩
children_sex_rate double ,–孩子性别概率
children_age_rate double ,–孩子年龄概率
is_have_car bigint ,–是否有车
potential_car_user_rate double ,–潜在汽车用户概率
phone_brand string ,–使用手机品牌
phone_brand_level string ,–使用手机品牌档次
phone_cnt bigint ,–使用多少种不同的手机
change_phone_rate bigint ,–更换手机频率
majia_flag string ,–马甲标志
majie_account_cnt bigint ,–马甲账号数量
loyal_model bigint ,–用户忠诚度
shopping_type_model bigint ,–用户购物类型
figure_model bigint ,–身材
stature_model bigint ,–身高
dw_date timestamp
) partitioned by (dt string);
–加载数据
insert overwrite table gdm.itcast_gdm_user_basic partition(dt=‘2017-01-01’)
select
t.user_id,
t.user_name,
t.user_sex,
t.user_birthday,
t.user_age,
t.constellation,
t.province,
t.city,
t.city_level,
t.hex_mail,
t.op_mail,
t.hex_phone,
t.fore_phone,
t.op_phone,
t.add_time,
t.login_ip,
t.login_source,
t.request_user,
t.total_mark,
t.used_mark,
t.level_name,
t.blacklist,
t.is_married,
t.education,
t.monthly_money,
t.profession,
null sex_model,–数据挖掘模型-开始
null is_pregnant_woman,
null is_have_children,
null children_sex_rate,
null children_age_rate,
null is_have_car,
null potential_car_user_rate,
null phone_brand,
null phone_brand_level,
null phone_cnt,
null change_phone_rate,
null majia_flag,
null majie_account_cnt,
null loyal_model,
null shopping_type_model,
null figure_model,
null stature_model,–数据挖掘模型-结束
from_unixtime(unix_timestamp()) dw_date
from (select * from fdm.itcast_fdm_user_wide where dt=‘2017-01-01’) t;
复制代码
itcast_gdm_user_basic.sh
复制代码
演示模型表开发脚本:
######################
#名称:客户基本属性模型表
itcast_gdm_user_basic.sh
######################
#!/bin/sh
yesterday=date -d '-1 day' "+%Y-%m-%d"
if [ $1 ];then
yesterday=
1
f
i
S
P
A
R
K
S
U
B
M
I
T
I
N
F
O
=
"
/
e
x
p
o
r
t
/
s
e
r
v
e
r
s
/
s
p
a
r
k
/
b
i
n
/
s
p
a
r
k
−
s
q
l
−
−
m
a
s
t
e
r
s
p
a
r
k
:
/
/
n
o
d
e
1
:
7077
−
−
e
x
e
c
u
t
o
r
−
m
e
m
o
r
y
1
g
−
−
t
o
t
a
l
−
e
x
e
c
u
t
o
r
−
c
o
r
e
s
2
−
−
c
o
n
f
s
p
a
r
k
.
s
q
l
.
w
a
r
e
h
o
u
s
e
.
d
i
r
=
h
d
f
s
:
/
/
n
o
d
e
1
:
9000
/
u
s
e
r
/
h
i
v
e
/
w
a
r
e
h
o
u
s
e
"
S
O
U
R
C
E
D
A
T
A
=
"
/
r
o
o
t
/
s
o
u
r
c
e
d
a
t
a
"
S
Q
L
B
D
M
=
"
c
r
e
a
t
e
d
a
t
a
b
a
s
e
i
f
n
o
t
e
x
i
s
t
s
b
d
m
;
c
r
e
a
t
e
e
x
t
e
r
n
a
l
t
a
b
l
e
i
f
n
o
t
e
x
i
s
t
s
b
d
m
.
i
t
c
a
s
t
b
d
m
u
s
e
r
(
u
s
e
r
i
d
s
t
r
i
n
g
,
−
−
用
户
I
D
u
s
e
r
n
a
m
e
s
t
r
i
n
g
,
−
−
用
户
登
陆
名
u
s
e
r
s
e
x
s
t
r
i
n
g
,
−
−
用
户
性
别
u
s
e
r
b
i
r
t
h
d
a
y
s
t
r
i
n
g
,
−
−
用
户
生
日
u
s
e
r
a
g
e
b
i
g
i
n
t
,
−
−
用
户
年
龄
c
o
n
s
t
e
l
l
a
t
i
o
n
s
t
r
i
n
g
,
−
−
用
户
星
座
p
r
o
v
i
n
c
e
s
t
r
i
n
g
,
−
−
省
份
c
i
t
y
s
t
r
i
n
g
,
−
−
城
市
c
i
t
y
l
e
v
e
l
s
t
r
i
n
g
,
−
−
城
市
等
级
h
e
x
m
a
i
l
s
t
r
i
n
g
,
−
−
邮
箱
o
p
m
a
i
l
s
t
r
i
n
g
,
−
−
邮
箱
运
营
商
h
e
x
p
h
o
n
e
s
t
r
i
n
g
,
−
−
手
机
号
f
o
r
e
p
h
o
n
e
s
t
r
i
n
g
,
−
−
手
机
前
3
位
o
p
p
h
o
n
e
s
t
r
i
n
g
,
−
−
手
机
运
营
商
a
d
d
t
i
m
e
s
t
r
i
n
g
,
−
−
注
册
时
间
l
o
g
i
n
i
p
s
t
r
i
n
g
,
−
−
登
陆
i
p
地
址
l
o
g
i
n
s
o
u
r
c
e
s
t
r
i
n
g
,
−
−
登
陆
来
源
r
e
q
u
e
s
t
u
s
e
r
s
t
r
i
n
g
,
−
−
邀
请
人
t
o
t
a
l
m
a
r
k
b
i
g
i
n
t
,
−
−
会
员
积
分
u
s
e
d
m
a
r
k
b
i
g
i
n
t
,
−
−
已
使
用
积
分
l
e
v
e
l
n
a
m
e
s
t
r
i
n
g
,
−
−
会
员
等
级
名
称
b
l
a
c
k
l
i
s
t
b
i
g
i
n
t
,
−
−
用
户
黑
名
单
i
s
m
a
r
r
i
e
d
b
i
g
i
n
t
,
−
−
婚
姻
状
况
e
d
u
c
a
t
i
o
n
s
t
r
i
n
g
,
−
−
学
历
m
o
n
t
h
l
y
m
o
n
e
y
d
o
u
b
l
e
,
−
−
收
入
p
r
o
f
e
s
s
i
o
n
s
t
r
i
n
g
−
−
职
业
)
p
a
r
t
i
t
i
o
n
e
d
b
y
(
d
t
s
t
r
i
n
g
)
r
o
w
f
o
r
m
a
t
d
e
l
i
m
i
t
e
d
f
i
e
l
d
s
t
e
r
m
i
n
a
t
e
d
b
y
′
,
′
l
o
c
a
t
i
o
n
′
/
b
u
s
i
n
e
s
s
/
b
d
m
/
i
t
c
a
s
t
b
d
m
u
s
e
r
′
;
a
l
t
e
r
t
a
b
l
e
b
d
m
.
i
t
c
a
s
t
b
d
m
u
s
e
r
a
d
d
p
a
r
t
i
t
i
o
n
(
d
t
=
′
1 fi SPARK_SUBMIT_INFO="/export/servers/spark/bin/spark-sql --master spark://node1:7077 --executor-memory 1g --total-executor-cores 2 --conf spark.sql.warehouse.dir=hdfs://node1:9000/user/hive/warehouse" SOURCE_DATA="/root/source_data" SQL_BDM="create database if not exists bdm; create external table if not exists bdm.itcast_bdm_user( user_id string ,--用户ID user_name string ,--用户登陆名 user_sex string ,--用户性别 user_birthday string ,--用户生日 user_age bigint ,--用户年龄 constellation string ,--用户星座 province string ,--省份 city string ,--城市 city_level string ,--城市等级 hex_mail string ,--邮箱 op_mail string ,--邮箱运营商 hex_phone string ,--手机号 fore_phone string ,--手机前3位 op_phone string ,--手机运营商 add_time string ,--注册时间 login_ip string ,--登陆ip地址 login_source string ,--登陆来源 request_user string ,--邀请人 total_mark bigint ,--会员积分 used_mark bigint ,--已使用积分 level_name string ,--会员等级名称 blacklist bigint ,--用户黑名单 is_married bigint ,--婚姻状况 education string ,--学历 monthly_money double ,--收入 profession string --职业 ) partitioned by (dt string) row format delimited fields terminated by ',' location '/business/bdm/itcast_bdm_user' ; alter table bdm.itcast_bdm_user add partition (dt='
1fiSPARKSUBMITINFO="/export/servers/spark/bin/spark−sql−−masterspark://node1:7077−−executor−memory1g−−total−executor−cores2−−confspark.sql.warehouse.dir=hdfs://node1:9000/user/hive/warehouse"SOURCEDATA="/root/sourcedata"SQLBDM="createdatabaseifnotexistsbdm;createexternaltableifnotexistsbdm.itcastbdmuser(useridstring,−−用户IDusernamestring,−−用户登陆名usersexstring,−−用户性别userbirthdaystring,−−用户生日useragebigint,−−用户年龄constellationstring,−−用户星座provincestring,−−省份citystring,−−城市citylevelstring,−−城市等级hexmailstring,−−邮箱opmailstring,−−邮箱运营商hexphonestring,−−手机号forephonestring,−−手机前3位opphonestring,−−手机运营商addtimestring,−−注册时间loginipstring,−−登陆ip地址loginsourcestring,−−登陆来源requestuserstring,−−邀请人totalmarkbigint,−−会员积分usedmarkbigint,−−已使用积分levelnamestring,−−会员等级名称blacklistbigint,−−用户黑名单ismarriedbigint,−−婚姻状况educationstring,−−学历monthlymoneydouble,−−收入professionstring−−职业)partitionedby(dtstring)rowformatdelimitedfieldsterminatedby′,′location′/business/bdm/itcastbdmuser′;altertablebdm.itcastbdmuseraddpartition(dt=′yesterday’);"
SQL_FDM=“create database if not exists fdm;
create table if not exists fdm.itcast_fdm_user_wide(
user_id string ,–用户ID
user_name string ,–用户登陆名
user_sex string ,–用户性别
user_birthday string ,–用户生日
user_age bigint ,–用户年龄
constellation string ,–用户星座
province string ,–省份
city string ,–城市
city_level string ,–城市等级
hex_mail string ,–邮箱
op_mail string ,–邮箱运营商
hex_phone string ,–手机号
fore_phone string ,–手机前3位
op_phone string ,–手机运营商
add_time string ,–注册时间
login_ip string ,–登陆ip地址
login_source string ,–登陆来源
request_user string ,–邀请人
total_mark bigint ,–会员积分
used_mark bigint ,–已使用积分
level_name string ,–会员等级名称
blacklist bigint ,–用户黑名单
is_married bigint ,–婚姻状况
education string ,–学历
monthly_money double ,–收入
profession string ,–职业
dw_date timestamp
) partitioned by (dt string);”
##加载数据
LOAD_FDM="
insert overwrite table fdm.itcast_fdm_user_wide partition(dt=‘
y
e
s
t
e
r
d
a
y
′
)
s
e
l
e
c
t
t
.
u
s
e
r
i
d
,
t
.
u
s
e
r
n
a
m
e
,
t
.
u
s
e
r
s
e
x
,
t
.
u
s
e
r
b
i
r
t
h
d
a
y
,
t
.
u
s
e
r
a
g
e
,
t
.
c
o
n
s
t
e
l
l
a
t
i
o
n
,
t
.
p
r
o
v
i
n
c
e
,
t
.
c
i
t
y
,
t
.
c
i
t
y
l
e
v
e
l
,
t
.
h
e
x
m
a
i
l
,
t
.
o
p
m
a
i
l
,
t
.
h
e
x
p
h
o
n
e
,
t
.
f
o
r
e
p
h
o
n
e
,
t
.
o
p
p
h
o
n
e
,
t
.
a
d
d
t
i
m
e
,
t
.
l
o
g
i
n
i
p
,
t
.
l
o
g
i
n
s
o
u
r
c
e
,
t
.
r
e
q
u
e
s
t
u
s
e
r
,
t
.
t
o
t
a
l
m
a
r
k
,
t
.
u
s
e
d
m
a
r
k
,
t
.
l
e
v
e
l
n
a
m
e
,
t
.
b
l
a
c
k
l
i
s
t
,
t
.
i
s
m
a
r
r
i
e
d
,
t
.
e
d
u
c
a
t
i
o
n
,
t
.
m
o
n
t
h
l
y
m
o
n
e
y
,
t
.
p
r
o
f
e
s
s
i
o
n
,
f
r
o
m
u
n
i
x
t
i
m
e
(
u
n
i
x
t
i
m
e
s
t
a
m
p
(
)
)
d
w
d
a
t
e
f
r
o
m
b
d
m
.
i
t
c
a
s
t
b
d
m
u
s
e
r
t
w
h
e
r
e
d
t
=
′
yesterday') select t.user_id, t.user_name, t.user_sex, t.user_birthday, t.user_age, t.constellation, t.province, t.city, t.city_level, t.hex_mail, t.op_mail, t.hex_phone, t.fore_phone, t.op_phone, t.add_time, t.login_ip, t.login_source, t.request_user, t.total_mark, t.used_mark, t.level_name, t.blacklist, t.is_married, t.education, t.monthly_money, t.profession, from_unixtime(unix_timestamp()) dw_date from bdm.itcast_bdm_user t where dt='
yesterday′)selectt.userid,t.username,t.usersex,t.userbirthday,t.userage,t.constellation,t.province,t.city,t.citylevel,t.hexmail,t.opmail,t.hexphone,t.forephone,t.opphone,t.addtime,t.loginip,t.loginsource,t.requestuser,t.totalmark,t.usedmark,t.levelname,t.blacklist,t.ismarried,t.education,t.monthlymoney,t.profession,fromunixtime(unixtimestamp())dwdatefrombdm.itcastbdmusertwheredt=′yesterday’;"
SQL_GDM=“create database if not exists gdm;
create table if not exists gdm.itcast_gdm_user_basic(
user_id string ,–用户ID
user_name string ,–用户登陆名
user_sex string ,–用户性别
user_birthday string ,–用户生日
user_age bigint ,–用户年龄
constellation string ,–用户星座
province string ,–省份
city string ,–城市
city_level string ,–城市等级
hex_mail string ,–邮箱
op_mail string ,–邮箱运营商
hex_phone string ,–手机号
fore_phone string ,–手机前3位
op_phone string ,–手机运营商
add_time string ,–注册时间
login_ip string ,–登陆ip地址
login_source string ,–登陆来源
request_user string ,–邀请人
total_mark bigint ,–会员积分
used_mark bigint ,–已使用积分
level_name string ,–会员等级名称
blacklist bigint ,–用户黑名单
is_married bigint ,–婚姻状况
education string ,–学历
monthly_money double ,–收入
profession string ,–职业
sex_model bigint ,–性别模型
is_pregnant_woman bigint ,–是否孕妇
is_have_children bigint ,–是否有小孩
children_sex_rate double ,–孩子性别概率
children_age_rate double ,–孩子年龄概率
is_have_car bigint ,–是否有车
potential_car_user_rate double,–潜在汽车用户概率
phone_brand string ,–使用手机品牌
phone_brand_level string ,–使用手机品牌档次
phone_cnt bigint ,–使用多少种不同的手机
change_phone_rate bigint ,–更换手机频率
majia_flag string ,–马甲标志
majie_account_cnt bigint ,–马甲账号数量
loyal_model bigint ,–用户忠诚度
shopping_type_model bigint ,–用户购物类型
figure_model bigint ,–身材
stature_model bigint ,–身高
dw_date timestamp
) partitioned by (dt string);”
##加载数据到GDM
LOAD_GDM=“insert overwrite table gdm.itcast_gdm_user_basic partition(dt=‘
y
e
s
t
e
r
d
a
y
′
)
s
e
l
e
c
t
t
.
u
s
e
r
i
d
,
t
.
u
s
e
r
n
a
m
e
,
t
.
u
s
e
r
s
e
x
,
t
.
u
s
e
r
b
i
r
t
h
d
a
y
,
t
.
u
s
e
r
a
g
e
,
t
.
c
o
n
s
t
e
l
l
a
t
i
o
n
,
t
.
p
r
o
v
i
n
c
e
,
t
.
c
i
t
y
,
t
.
c
i
t
y
l
e
v
e
l
,
t
.
h
e
x
m
a
i
l
,
t
.
o
p
m
a
i
l
,
t
.
h
e
x
p
h
o
n
e
,
t
.
f
o
r
e
p
h
o
n
e
,
t
.
o
p
p
h
o
n
e
,
t
.
a
d
d
t
i
m
e
,
t
.
l
o
g
i
n
i
p
,
t
.
l
o
g
i
n
s
o
u
r
c
e
,
t
.
r
e
q
u
e
s
t
u
s
e
r
,
t
.
t
o
t
a
l
m
a
r
k
,
t
.
u
s
e
d
m
a
r
k
,
t
.
l
e
v
e
l
n
a
m
e
,
t
.
b
l
a
c
k
l
i
s
t
,
t
.
i
s
m
a
r
r
i
e
d
,
t
.
e
d
u
c
a
t
i
o
n
,
t
.
m
o
n
t
h
l
y
m
o
n
e
y
,
t
.
p
r
o
f
e
s
s
i
o
n
,
n
u
l
l
s
e
x
m
o
d
e
l
,
−
−
数
据
挖
掘
模
型
−
开
始
n
u
l
l
i
s
p
r
e
g
n
a
n
t
w
o
m
a
n
,
n
u
l
l
i
s
h
a
v
e
c
h
i
l
d
r
e
n
,
n
u
l
l
c
h
i
l
d
r
e
n
s
e
x
r
a
t
e
,
n
u
l
l
c
h
i
l
d
r
e
n
a
g
e
r
a
t
e
,
n
u
l
l
i
s
h
a
v
e
c
a
r
,
n
u
l
l
p
o
t
e
n
t
i
a
l
c
a
r
u
s
e
r
r
a
t
e
,
n
u
l
l
p
h
o
n
e
b
r
a
n
d
,
n
u
l
l
p
h
o
n
e
b
r
a
n
d
l
e
v
e
l
,
n
u
l
l
p
h
o
n
e
c
n
t
,
n
u
l
l
c
h
a
n
g
e
p
h
o
n
e
r
a
t
e
,
n
u
l
l
m
a
j
i
a
f
l
a
g
,
n
u
l
l
m
a
j
i
e
a
c
c
o
u
n
t
c
n
t
,
n
u
l
l
l
o
y
a
l
m
o
d
e
l
,
n
u
l
l
s
h
o
p
p
i
n
g
t
y
p
e
m
o
d
e
l
,
n
u
l
l
f
i
g
u
r
e
m
o
d
e
l
,
n
u
l
l
s
t
a
t
u
r
e
m
o
d
e
l
,
−
−
数
据
挖
掘
模
型
−
结
束
f
r
o
m
u
n
i
x
t
i
m
e
(
u
n
i
x
t
i
m
e
s
t
a
m
p
(
)
)
d
w
d
a
t
e
f
r
o
m
(
s
e
l
e
c
t
∗
f
r
o
m
f
d
m
.
i
t
c
a
s
t
f
d
m
u
s
e
r
w
i
d
e
w
h
e
r
e
d
t
=
′
yesterday') select t.user_id, t.user_name, t.user_sex, t.user_birthday, t.user_age, t.constellation, t.province, t.city, t.city_level, t.hex_mail, t.op_mail, t.hex_phone, t.fore_phone, t.op_phone, t.add_time, t.login_ip, t.login_source, t.request_user, t.total_mark, t.used_mark, t.level_name, t.blacklist, t.is_married, t.education, t.monthly_money, t.profession, null sex_model,--数据挖掘模型-开始 null is_pregnant_woman, null is_have_children, null children_sex_rate, null children_age_rate, null is_have_car, null potential_car_user_rate, null phone_brand, null phone_brand_level, null phone_cnt, null change_phone_rate, null majia_flag, null majie_account_cnt, null loyal_model, null shopping_type_model, null figure_model, null stature_model,--数据挖掘模型-结束 from_unixtime(unix_timestamp()) dw_date from (select * from fdm.itcast_fdm_user_wide where dt='
yesterday′)selectt.userid,t.username,t.usersex,t.userbirthday,t.userage,t.constellation,t.province,t.city,t.citylevel,t.hexmail,t.opmail,t.hexphone,t.forephone,t.opphone,t.addtime,t.loginip,t.loginsource,t.requestuser,t.totalmark,t.usedmark,t.levelname,t.blacklist,t.ismarried,t.education,t.monthlymoney,t.profession,nullsexmodel,−−数据挖掘模型−开始nullispregnantwoman,nullishavechildren,nullchildrensexrate,nullchildrenagerate,nullishavecar,nullpotentialcaruserrate,nullphonebrand,nullphonebrandlevel,nullphonecnt,nullchangephonerate,nullmajiaflag,nullmajieaccountcnt,nullloyalmodel,nullshoppingtypemodel,nullfiguremodel,nullstaturemodel,−−数据挖掘模型−结束fromunixtime(unixtimestamp())dwdatefrom(select∗fromfdm.itcastfdmuserwidewheredt=′yesterday’) t;”
##创建BDM层表
echo “${SQL_BDM}”
S
P
A
R
K
S
U
B
M
I
T
I
N
F
O
−
e
"
SPARK_SUBMIT_INFO -e "
SPARKSUBMITINFO−e"{SQL_BDM}"
##添加数据到BDM
hdfs dfs -put
S
O
U
R
C
E
D
A
T
A
/
i
t
c
a
s
t
b
d
m
u
s
e
r
.
t
x
t
/
b
u
s
i
n
e
s
s
/
b
d
m
/
i
t
c
a
s
t
b
d
m
u
s
e
r
/
"
d
t
=
SOURCE_DATA/itcast_bdm_user.txt /business/bdm/itcast_bdm_user/"dt=
SOURCEDATA/itcastbdmuser.txt/business/bdm/itcastbdmuser/"dt=yesterday"
##创建FDM层表
echo “${SQL_FDM}”
S
P
A
R
K
S
U
B
M
I
T
I
N
F
O
−
e
"
SPARK_SUBMIT_INFO -e "
SPARKSUBMITINFO−e"{SQL_FDM}"
##导入数据到FDM
echo “${LOAD_FDM}”
S
P
A
R
K
S
U
B
M
I
T
I
N
F
O
−
e
"
SPARK_SUBMIT_INFO -e "
SPARKSUBMITINFO−e"{LOAD_FDM}"
##创建GDM层表
echo “${SQL_GDM}”
S
P
A
R
K
S
U
B
M
I
T
I
N
F
O
−
e
"
SPARK_SUBMIT_INFO -e "
SPARKSUBMITINFO−e"{SQL_GDM}"
##导入GDM数据
echo “${LOAD_GDM}”
S
P
A
R
K
S
U
B
M
I
T
I
N
F
O
−
e
"
SPARK_SUBMIT_INFO -e "
SPARKSUBMITINFO−e"{LOAD_GDM}"
USB Microphone https://www.soft-voice.com/
Wooden Speakers https://www.zeshuiplatform.com/
亚马逊测评 www.yisuping.cn
深圳网站建设www.sz886.com