欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

首頁綜合 正文
目錄

柚子快報邀請碼778899分享:大數(shù)據(jù) 數(shù)據(jù)倉庫

柚子快報邀請碼778899分享:大數(shù)據(jù) 數(shù)據(jù)倉庫

http://yzkb.51969.com/

? ? ?今天面試問到了一個問題,假設我們的用戶信息是天級別統(tǒng)計的,那么如果計算多天的留存與回訪就需要掃描多個分區(qū),這樣計算資源比較多,如何進行優(yōu)化。

首先要介紹一下,留存,回訪,lt 這3個基本概念

基本概念

n日留存 :n日后是否訪問app

n日回訪 :n日活是否訪問某個業(yè)務模塊(app中的某一板塊,當這個板塊為app時,留存==回訪),類似于留存

lt? :? ?用戶的生命周期,相當于整體的活躍天數(shù)。 詳細參考 :用戶全生命周期價值(LTV)指標如何計算 - 傳播蛙

思路

我們需要構(gòu)建map存儲用戶的歷史活躍天數(shù),然后利用日期作為key進行快速索引

構(gòu)建歷史全量活躍天數(shù)表?

with all_act_tmp as (

select

device_id,

map('${date}',1) as act_date_map

from test_dwd.dwd_user_device_active_di

where date = '${date}'

union all

select

device_id,

act_date_map

from test_dwd.user_dwd_device_active_df

where date = '${date-1}'

)

insert overwrite table test_dwd.user_dwd_device_active_df partition(date='${date}')

select

device_id,

union_map(act_date_map)

from

all_act_tmp

group by device_id

計算相關(guān)指標

select

device_id,

map_keys(act_date_map) as act_date_list

size(act_date_map) as all_lt_cnt,

if(act_date_map['${date}']=1,1,0) as is_act,

if(act_date_map['${date-1}'=1,1,0]) as is_act_1d,

if(act_date_map['${date-3}'=1,1,0]) as is_act_3d,

if(act_date_map['${date-7}'=1,1,0]) as is_act_7d,

...

size(sub_map(act_date_map,'${date-2}','${date}')) as lt_3d,

size(sub_map(act_date_map,'${date-6}','${date}')) as lt_7d,

size(sub_map(act_date_map,'${date-14}','${date}')) as lt_15d

...

from

test_dwd.user_dwd_device_active_df

相關(guān)功能函數(shù)

sub_map 函數(shù) UDF ?

sub_map(map,start,end,byKey) - Returns a sub map from mao, in which key(or value) is between start and end

柚子快報邀請碼778899分享:大數(shù)據(jù) 數(shù)據(jù)倉庫

http://yzkb.51969.com/

好文閱讀

評論可見,查看隱藏內(nèi)容

本文內(nèi)容根據(jù)網(wǎng)絡資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。

轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/19021689.html

發(fā)布評論

您暫未設置收款碼

請在主題配置——文章設置里上傳

掃描二維碼手機訪問

文章目錄