DWD层
初始化脚本,这个脚本和ODS层
的初始化脚本代码完全一致,只不过数据被保存到了DWD层
。
> cd /home/work/warehouse_goods_order
> vi dwd_shopmall_init.sh
#!/bin/bash
# dwd层数据库和表初始化,只需要执行一次
hive -e "
create database if not exists dwd_shopmall;
create external table if not exists dwd_shopmall.dwd_user (
id bigint,
username string,
gender tinyint,
birthday string,
email string,
mobile string,
createtime string,
disabled tinyint
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/user/';
create external table if not exists dwd_shopmall.dwd_user_addr (
id bigint,
userid bigint,
addrname string,
isdefault tinyint,
username string,
mobile string
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/user_addr/';
create external table if not exists dwd_shopmall.dwd_category (
id int,
parentids string,
name string,
level int,
createtime string
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/category/';
create external table if not exists dwd_shopmall.dwd_goods_info (
id bigint,
name string,
desc string,
price double,
categoryid int,
createtime string
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/goods_info/';
create external table if not exists dwd_shopmall.dwd_payment (
id bigint,
orderid bigint,
tradeno string,
money double,
type int,
createtime string
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/payment/';
create external table if not exists dwd_shopmall.dwd_order (
id bigint,
userid bigint,
money double,
type int,
status int,
payid bigint,
createtime string,
updatetime string
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/order/';
create external table if not exists dwd_shopmall.dwd_orderitem (
orderid bigint,
goodsid bigint,
amount int,
price double,
createtime string
) partitioned by(dt string)
row format delimited
fields terminated by '\t'
location 'hdfs://server01:9000/data/dwd/orderitem/';
"
原创大约 2 分钟