码迷,mamicode.com
首页 > 数据库 > 详细

ods_to_dwd_sql

时间:2021-02-23 14:36:54      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:open   log   detail   star   user   app   nal   lan   bsp   

主要是这两个sql

 

start_log(利用get_json_object函数):

insert overwrite table "$app".dwd_start_log 
PARTITION (dt=$do_date) 
select 
    get_json_object(line,$.mid) mid_id, 
    get_json_object(line,$.uid) user_id, 
    get_json_object(line,$.vc) version_code, 
    get_json_object(line,$.vn) version_name, 
    get_json_object(line,$.l) lang, 
    get_json_object(line,$.sr) source, 
    get_json_object(line,$.os) os, 
    get_json_object(line,$.ar) area, 
    get_json_object(line,$.md) model, 
    get_json_object(line,$.ba) brand, 
    get_json_object(line,$.sv) sdk_version,
    get_json_object(line,$.g) gmail, 
    get_json_object(line,$.hw) height_width, 
    get_json_object(line,$.t) app_time, 
    get_json_object(line,$.nw) network, 
    get_json_object(line,$.ln) lng, 
    get_json_object(line,$.la) lat, 
    get_json_object(line,$.entry) entry, 
    get_json_object(line,$.open_ad_type) open_ad_type, 
    get_json_object(line,$.action) action, 
    get_json_object(line,$.loading_time) loading_time, 
    get_json_object(line,$.detail) detail, 
    get_json_object(line,$.extend1) extend1
from "$app".ods_start_log 
where dt=$do_date;
"

 

 

base_event(利用UDF,UDTF函数):

use "$APP"; 
insert overwrite table "$APP".dwd_base_event_log partition(dt=$do_date) 
select base_analizer(line,mid) as mid_id, 
base_analizer(line,uid) as user_id, 
base_analizer(line,vc) as version_code, 
base_analizer(line,vn) as version_name, 
base_analizer(line,l) as lang, 
base_analizer(line,sr) as source, 
base_analizer(line,os) as os, 
base_analizer(line,ar) as area,
base_analizer(line,md) as model, 
base_analizer(line,ba) as brand, 
base_analizer(line,sv) as sdk_version, 
base_analizer(line,g) as gmail, 
base_analizer(line,hw) as height_width, 
base_analizer(line,t) as app_time, 
base_analizer(line,nw) as network, 
base_analizer(line,ln) as lng, 
base_analizer(line,la) as lat, 
event_name, 
event_json, 
base_analizer(line,st) as server_time 
from "$APP".ods_event_log 
lateral view flat_analizer(base_analizer(line,et)) tem_flat as event_name,event_json 
where dt=$do_date and base_analizer(line,et)<>‘‘;
"

 

ods_to_dwd_sql

标签:open   log   detail   star   user   app   nal   lan   bsp   

原文地址:https://www.cnblogs.com/ldy233/p/14435361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!