订单明细事实表
属于周期型快照事实表
类似的有支付事实表,退款事实表,评价事实表
-- 建表 drop table if exists dwd_fact_order_detail; create external table dwd_fact_order_detail ( `id` string COMMENT '订单编号', `order_id` string COMMENT '订单号', `user_id` string COMMENT '用户 id', `sku_id` string COMMENT 'sku 商品 id', `sku_name` string COMMENT '商品名称', `order_price` decimal(10,2) COMMENT '商品价格', `sku_num` bigint COMMENT '商品数量', `create_time` string COMMENT '创建时间', `province_id` string COMMENT '省份 ID', `total_amount` decimal(20,2) COMMENT '订单总金额' ) PARTITIONED BY (`dt` string) stored as parquet location '/warehouse/gmall/dwd/dwd_fact_order_detail/' tblproperties ("parquet.compression"="lzo"); -- 插入 insert overwrite table dwd_fact_order_detail partition(dt='2020-03-10') select od.id, od.order_id, od.user_id, od.sku_id, od.sku_name, od.order_price, od.sku_num, od.create_time, oi.province_id, od.order_price*od.sku_num from ( select * from ods_order_detail where dt='2020-03-10' ) od join ( select * from ods_order_info where dt='2020-03-10' ) oi on od.order_id=oi.id;