3.4DWD层
对ODS层数据进行判空过滤。对商品分类表进行维度退化(降维)。
3.4.1 创建订单表
hive (gmall)>
drop table if exists dwd_order_info;
create external table dwd_order_info (
id
string COMMENT ‘’,
total_amount
decimal(10,2) COMMENT ‘’,
order_status
string COMMENT ’ 1234 5’,
user_id
string COMMENT ‘id’,
payment_way
string COMMENT ‘’,
out_trade_no
string COMMENT ‘’,
create_time
string COMMENT ‘’,
operate_time
string COMMENT ‘’
)
PARTITIONED BY (dt
string)
stored as parquet
location ‘/warehouse/gmall/dwd/dwd_order_info/’
tblproperties (“parquet.compression”=“snappy”)
;
3.4.2创建订单详情表
hive (gmall)>
drop table if exists dwd_order_detail;
create external table dwd_order_detail(
id
string COMMENT ‘’,
order_id
decimal(10,2) COMMENT ‘’,
user_id
string COMMENT ‘id’,
sku_id
string COMMENT ‘id’,
sku_name
string COMMENT ‘’,
order_price
string COMMENT ‘’,
sku_num
string COMMENT ‘’,
create_time
string COMMENT ‘’
)
PARTITIONED BY (dt
string)
stored as parquet
location ‘/warehouse/gmall/dwd/dwd_order_detail/’
tblproperties (“parquet.compression”=“snappy”)
;
3.4.3创建用户表
hive (gmall)>
drop table if exists dwd_user_info;
create external table dwd_user_info(
id
string COMMENT ‘id’,
name
string COMMENT ‘’,
birthday
string COMMENT ‘’,
gender
string COMMENT ‘’,
email
string COMMENT ‘’,
user_level
string COMMENT ‘’,
create_time
string COMMENT ‘’
)
PARTITIONED BY (dt
string)
stored as parquet
location ‘/warehouse/gmall/dwd/dwd_user_info/’
tblproperties (“parquet.compression”=“snappy”)
;
3.4.4创建支付流水表
hive (gmall)>
drop table if exists dwd_payment_info;
create external table dwd_payment_info(
id
bigint COMMENT ‘’,
out_trade_no
string COMMENT ‘’,
order_id
string COMMENT ‘’,
user_id
string COMMENT ‘’,
alipay_trade_no
string COMMENT ‘’,
total_amount
decimal(16,2) COMMENT ‘’,
subject
string COMMENT ‘’,
payment_type
string COMMENT ‘’,
payment_time
string COMMENT ‘’
)
PARTITIONED BY (dt
string)
stored as parquet
location ‘/warehouse/gmall/dwd/dwd_payment_info/’
tblproperties (“parquet.compression”=“snappy”)
;
3.4.5创建商品表(增加分类)
hive (gmall)>
drop table if exists dwd_sku_info;
create external table dwd_sku_info(
id
string COMMENT ‘skuId’,
spu_id
string COMMENT ‘spuid’,
price
decimal(10,2) COMMENT ‘’,
sku_name
string COMMENT ‘’,
sku_desc
string COMMENT ‘’,
weight
string COMMENT ‘’,
tm_id
string COMMENT ‘id’,
category3_id
string COMMENT ‘1id’,
category2_id
string COMMENT ‘2id’,
category1_id
string COMMENT ‘3id’,
category3_name
string COMMENT ‘3’,
category2_name
string COMMENT ‘2’,
category1_name
string COMMENT ‘1’,
create_time
string COMMENT ‘’
)
PARTITIONED BY (dt
string)
stored as parquet
location ‘/warehouse/gmall/dwd/dwd_sku_info/’
tblproperties (“parquet.compression”=“snappy”)
;