美文网首页
记一次需求处理过程

记一次需求处理过程

作者: 大道至简_6a43 | 来源:发表于2020-07-06 09:54 被阅读0次

3、去过xx的人也喜欢yy

 计算口径:所有账户(username,过滤大单用户账号)取最近5个订单,求某个账号任意2个航线的共现次数,除以2个航线单独出现次数的乘积,得到结果作为相关性(百分比)

用户A: a-b a-c

用户B :a-b

用户C: a-c

则用户A,a-b与a-c相关性=1/2*2=25%

 Key:username

 Value:两个相关航线-相关性百分比

如:a-b&a-c&25%

drop table if exists tmp_data;

create table tmp_data as

select

  username,

  air_line

from(

  select

    username,

    air_line,

    create_time,

    row_number() over(partition by username order by create_time) ranks

  from(

    select

      qunar_username,

      concat(act_dep_city,'-',act_arr_city) air_line,

      max(create_time) as create_time

    from f_wide.wide_order

    where  dt>='$QDATE(-730,'yyyyMMdd')' and pay_ok=1 and dom_inter=0

    group by username,concat(act_dep_city,'-',act_arr_city)

  )A

)A where ranks<=5;

insert overwrite table user_air_line_similar partition(dt)

select

  username,

  concat_ws(',',udf.collect_list_sort(concat(B.air_line,'&',couple_air_line,'&',rate),rn)),

  '$QDATE(0,'yyyyMMdd')' dt

from tmp_data A

join(

  select

    air_line,

    couple_air_line,

    round(couple_num*1.0/(a_airline_num*b_airline_num),4) as rate,

    row_number() over(partition by air_line order by couple_num*1.0/(a_airline_num*b_airline_num) desc ) as rn --取出所有包含A航线的,的组合方式,并排名

  from(

    select

      A.air_line as air_line,

      b_air_line as couple_air_line,

      a_airline_num,

      b_airline_num,

      count(distinct username) as couple_num--针对每一种航线组合,对用户名去重后,取总的组合次数

    from(

      select

        A.username,

        A.air_line air_line,

        B.air_line b_air_line,

        count(distinct A.username) over (partition by A.air_line) as a_airline_num,--针对每一个航线对用户名去重,然后取出每一个航线总的售卖量

        count(distinct A.username) over (partition by B.air_line) as b_airline_num

      from tmp_data A

      join tmp_data B on (A.username=B.username)

      where split(A.air_line,'-')[0] = split(B.air_line,'-')[0] and split(A.air_line,'-')[1] <> split(B.air_line,'-')[1]

    )A

    group by

      A.air_line,

      b_air_line,

      a_airline_num,

      b_airline_num

  )A

)B on (A.air_line=B.air_line and B.rn<=20)--A航线的组合方式以及排名已经出来只取前二十,用A表中的航线跟B中的航线组合中的一个航线进行join,就得到A表中的航线跟其他航线的组合的概率了。

group by A.username

distribute by dt;

相关文章

  • 记一次需求处理过程

    3、去过xx的人也喜欢yy  计算口径:所有账户(username,过滤大单用户账号)取最近5个订单,求某个账号...

  • 倒排索引案例(多Job串联)

    需求 需求分析 第一次处理 OneIndexMapper public class OneIndexMapper ...

  • 思路反思

    针对需要对上一次过程的变化和现在变化的对比有比较的循环过程需求,可以预先设置一个变量,先处理完过程后,再把当前的变...

  • 记一次OOM查询处理过程

    问题的爆出及分析排查现场 排查后的解决方案 项目的jvm参数 总结 一、问题的爆出及分析排查现场 服务偶尔会出现不...

  • oc-swift混编之oc调用swift

    前言 记一次oc项目中引用swift开源库处理过程 开源库 测试使用这个开源库 该库太老,现在swif都到4.1了...

  • 记一次MySQL数据库进程占用CPU过高问题及处理过程

    RT:记一次MySQL数据库进程占用CPU过高问题及处理过程 场景:本人医院信息科员工 事件:检查预约系统每天8:...

  • 记一次ceph pg unfound处理过程

    今天检查ceph集群,发现有pg丢失,于是就有了本文~~~ 1.查看集群状态 从输出发现pg 2.2b is ac...

  • 记一次学生打架的处理过程

    “咚咚咚”。楼上发出了刺耳的声音。 这是怎么回事儿?在装修吗?还是发生了什么? 竖起耳朵认真听。 “我没有,我没有...

  • 记一次漫长的蓝屏处理过程

    2022年5月9日 星期一 事情前奏 一台神舟K670E-G6E3的笔记本电脑,18年入手一直没出现过什么问题。想...

  • 需求过程-需求管理

    需求管理就是要简历需求基线并建立需求跟踪能力联系链,确保所有用户需求都被正确地应用,并且在需求发生变更时,能够完全...

网友评论

      本文标题:记一次需求处理过程

      本文链接:https://www.haomeiwen.com/subject/hoxwqktx.html