- 博客(6)
- 收藏
- 关注
原创 hive sql 中join引起的数据倾斜之mapjoin优化
在dwd层关联维度表时经常会遇到数据倾斜,假如某app商店的曝光数据超百亿,在关联app维度表表时,排在前面的app肯定占了大部分数据,如抖音微信,肯定会遇到数据倾斜。这个时候该怎么解决呢? mapjoin无疑是比较好的选择!步骤1:先建个临时表,筛选5000万以上的数据CREATE TABLE temp_store_exposure_dmAS SELECT t1.app_id,t2.app_name,t2.app_categoryFROM ( SELECT app_...
2021-12-31 23:25:42
707
原创 hive sql里全量表如何计算上月累积,本月累积值
hive里假设:dws_store_install_ds 为历史安装全量表dws_store_install_dm为天增量表如下逻辑是 计算上月累积,本月累积值 的逻辑INSERT OVERWRITE TABLE dws_hispace_install_ds(pt_d='$date')SELECT IF(t2.app_id is null ,t1.app_id,t2.app_id),NVL(install_cnt,0)
2021-12-31 21:49:10
1036
原创 sql计算周月同比
首先看一下全量表的明细数据对明细数据进行聚合方法一 :自关联 --笛卡尔积先看一下笛卡尔积的结果select*from( select count(*) as cnt,app_id,down_date from dwd_hispace_down_ds group by app_id,down_date) aleft join( select count(*) as cnt,app_id,down_date from dwd_hispace_d
2021-12-27 22:13:18
1359
原创 sql留存率简单的小应用
简单描述一下在这里插入代码片select‘2021-01-01’,sum(second)/count() second_keep,sum(seven)/count() seven_keepfrom(selectuser_id,sum( case when diff = 1 then 1 else 0 end) as second,sum( case when diff = 7 then 1 else 0 end) as sevenfrom(selectuser_id
2021-12-26 21:15:02
350
原创 全外关联full outer join 实现全量表的更新
全外关联full outer join 实现增量tab1 为原表,tab3为增加的数据;select nvl(a.id,b.id),nvl(a.value,b.value)from tab3 afull join tab1 b on a.id=b.id
2021-03-11 21:25:49
374
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人