Hadoop大数据

数仓--DW--Hadoop数仓实践Case-08-退化维度

2019-04-16  本文已影响79人  李小李的路

退化维度概述

退化订单维度

修改定期装载脚本

-- 修改dw.sale_order_fact名称,重命名
alter table dw.sale_order_fact rename to dw.sale_order_fact_old;
-- 创建新表,添加order_number列
create table 
    dw.sale_order_fact(
    order_number int comment 'order_number',
    customer_sk int comment 'customer surrogate key',
    product_sk int comment 'product surrogate key',
    order_date_sk string comment 'date surrogate key',
    request_delivery_date_sk int comment 'request_delivery_date_sk',
    order_amount decimal (10 , 2 ) comment'order amount',
    order_quantity int comment 'order_quantity'
    )
clustered by (order_number)
into 8 buckets
stored as orc tblproperties('transactional'='true');
-- 将数据插入到新建的表中
insert into table
    dw.sale_order_fact
select
    t2.order_number,
    t1.customer_sk,
    t1.product_sk,
    t1.order_date_sk,
    t1.request_delivery_date_sk,
    t1.order_amount,
    t1.order_quantity
from 
    dw.sale_order_fact_old t1
inner join
    source.source_order_dim t2
on
    t1.order_sk=t2.order_key;
-- 删除旧表中的数据
drop table dw.sale_order_fact_old;
上一篇下一篇

猜你喜欢

热点阅读