大数据---DIM层数据处理

本文介绍了如何在Hive中优化配置以处理大规模维度表数据,包括动态分区设置、压缩策略,以及如何将数据导出至PostgreSQL数据库。同时涉及了Zookeeper的分布式协调服务和数据模型,强调一致性保证在数据处理中的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、处理维度表数据

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;
门店商品表
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值