一、ODS层建表与数据加载
### --- ODS建表:
~~~ ODS层的表结构与源数据基本类似(列名及数据类型);
~~~ ODS层的表名遵循统一的规范;
~~~ 所有的表都是分区表;字段之间的分隔符为, ;为表的数据数据文件指定了位置;
二、ODS层建表与数据加载
### --- ODS层建表:订单表
DROP TABLE IF EXISTS `ods.ods_trade_orders`;
CREATE EXTERNAL TABLE `ods.ods_trade_orders`(
`orderid` int,
`orderno` string,
`userid` bigint,
`status` tinyint,
`productmoney` decimal(10, 0),
`totalmoney` decimal(10, 0),
`paymethod` tinyint,
`ispay` tinyint,
`areaid` int,
`tradesrc` tinyint,
`tradetype` int,
`isrefund` tinyint,
`dataflag` tinyint,
`createtime` string,
`paytime` string,
`modifiedtime` string)
COMMENT '订单表'
PARTITIONED BY (`dt` string)
row format delimited fields terminated by ','
location '/user/data/trade.db/orders/';
### --- ODS层建表:订单明细表
DROP TABLE IF EXISTS `ods.ods_trade_order_product`;
CREATE EXTERNAL TABLE `ods.ods_trade_order_product`(
`id` string,
`orderid` decimal(10