一、处理维度表数据
hive的配置
-- 开启动态分区方案 -- 开启非严格模式 set hive.exec.dynamic.partition.mode=nonstrict; -- 开启动态分区支持(默认true) set hive.exec.dynamic.partition=true; -- 设置各个节点生成动态分区的最大数量: 默认为100个 (一般在生产环境中, 都需要调整更大) set hive.exec.max.dynamic.partitions.pernode=10000; -- 设置最大生成动态分区的数量: 默认为1000 (一般在生产环境中, 都需要调整更大) set hive.exec.max.dynamic.partitions=100000; -- hive一次性最大能够创建多少个文件: 默认为10w set hive.exec.max.created.files=150000; -- hive压缩 -- 开启中间结果压缩 set hive.exec.compress.intermediate=true; -- 开启最终结果压缩 set hive.exec.compress.output=true; -- 写入时压缩生效 set hive.exec.orc.compression.strategy=COMPRESSION;
分类表
分类表(
ods_dim_category_f
)拉平处理![]()
insert overwrite table dwd_dim_category_statistics_i partition(dt) select t1.id, t1.category_no, t1.category_name, t2.id, t2.category_no, t2.category_name, t3.id, t3.category_no, t3.category_name, 0 status, date_add(current_date,-1) dt from dim.ods_dim_category_f t1 join dim.ods_dim_category_f t2 on t1.id = t2.parent_id join dim.ods_dim_category_f t3 on t2.id = t3.parent_id
商品表
商品表(
ods_dim_goods_info_f
)处理将分类编号替换为一二三级分类ID、编码和名称
关联分类表,将商品表中的category_no 对应的是分类表中的三级分类
insert into dwd_dim_goods_i partition (dt) select id, goods_no, goods_name, first_category_id, first_category_no, first_category_name, second_category_id, second_category_no, second_category_name, third_category_id, third_category_no, third_category_name, brand_no, spec, sale_unit, life_cycle_status, tax_rate_status, tax_rate, tax_value, order_multiple, pack_qty, split_type, is_sell_by_piece, is_self_support, is_variable_price, is_double_measurement, is_must_sell, is_seasonal, seasonal_start_time, seasonal_end_time, is_deleted, goods_type, create_time, update_time, date_add(current_date, -1) dt from ods_dim_goods_info_f t1 left join dwd_dim_category_statistics_i t2 on t1.category_no = t2.third_category_no;