zoukankan      html  css  js  c++  java
  • dwt_uv_topic

    sql:

    dwt_uv_topic没有分区,记载累计的结果

    与dws_uv_detail_daycount表最新分区进行full outer join 就能获得累积的数据

    drop table if exists dwt_uv_topic; 
    create external table dwt_uv_topic 
    ( 
        `mid_id` string COMMENT '设备唯一标识', 
        `user_id` string COMMENT '用户标识', 
        `version_code` string COMMENT '程序版本号', 
        `version_name` string COMMENT '程序版本名', 
        `lang` string COMMENT '系统语言', 
        `source` string COMMENT '渠道号', 
        `os` string COMMENT '安卓系统版本', 
        `area` string COMMENT '区域', 
        `model` string COMMENT '手机型号', 
        `brand` string COMMENT '手机品牌', 
        `sdk_version` string COMMENT 'sdkVersion', 
        `gmail` string COMMENT 'gmail', 
        `height_width` string COMMENT '屏幕宽高', 
        `app_time` string COMMENT '客户端日志产生时的时间', 
        `network` string COMMENT '网络模式',
        `lng` string COMMENT '经度', 
        `lat` string COMMENT '纬度', 
        `login_date_first` string comment '首次活跃时间', 
        `login_date_last` string comment '末次活跃时间', 
        `login_day_count` bigint comment '当日活跃次数', 
        `login_count` bigint comment '累积活跃天数' 
    )
    stored as parquet 
    location '/ecdw/dwt/dwt_uv_topic';
    
    
    -- 插入
    insert overwrite table dwt_uv_topic 
    select 
        nvl(new.mid_id,old.mid_id), 
        nvl(new.user_id,old.user_id), 
        nvl(new.version_code,old.version_code), 
        nvl(new.version_name,old.version_name), 
        nvl(new.lang,old.lang), nvl(new.source,old.source),
        nvl(new.os,old.os), nvl(new.area,old.area), 
        nvl(new.model,old.model), nvl(new.brand,old.brand), 
        nvl(new.sdk_version,old.sdk_version), 
        nvl(new.gmail,old.gmail), 
        nvl(new.height_width,old.height_width), 
        nvl(new.app_time,old.app_time), 
        nvl(new.network,old.network), 
        nvl(new.lng,old.lng), 
        nvl(new.lat,old.lat), 
        if(old.mid_id is null,'2020-03-12',old.login_date_first), 
        if(new.mid_id is not null,'2020-03-12',old.login_date_last), 
        if(new.mid_id is not null, new.login_count,0), 
        nvl(old.login_count,0)+if(new.login_count>0,1,0) 
    from 
    ( 
    select 
        * 
    from dwt_uv_topic 
    )old 
    full outer join 
    ( 
    select 
        * 
    from dws_uv_detail_daycount 
    where dt='2020-03-12' 
    )new 
    on old.mid_id=new.mid_id;
  • 相关阅读:
    python 希尔排序
    python 选择排序
    python 插入排序
    怎么根据返回数量,来渲染点赞星星的个数变高量?
    avalon $computed不起作用?
    移动端点击事件兼容问题,在pc端可以点,在手机上不可以点
    移动端弹出遮罩层禁止页面滚动,遮罩里面的框允许滚动如何实现。
    移动端,如何禁止弹窗下面内容滚动/页面滚动
    avalon数据已更新,视图未更新的bug修复
    Python 导入分部分项前的 数据处理
  • 原文地址:https://www.cnblogs.com/ldy233/p/14437277.html
Copyright © 2011-2022 走看看