Commit 0671e724 authored by 王志伟's avatar 王志伟

查找无点击老用户

parent 26fc2796
...@@ -901,76 +901,89 @@ object find_reason { ...@@ -901,76 +901,89 @@ object find_reason {
old_clk_device.createOrReplaceTempView("old_clk_device") old_clk_device.createOrReplaceTempView("old_clk_device")
//1.1无点击的老用户
//2.当天新用户中的点击用户数 val old_noclk_device = sc.sql(
val new_clk_count = sc.sql(
s""" s"""
|select '${stat_date}' as stat_date,count(distinct(oc.device_id)) as new_clk_count |select device_id
|from all_clk_diary_card oc inner join device_id_new |from device_id_old
|on oc.device_id = device_id_new.device_id |except
|select device_id
|from old_clk_device
""".stripMargin """.stripMargin
) )
//2.1 有点击的新用户 old_noclk_device.show()
val new_clk_device = sc.sql(
s"""
|select distinct(oc.device_id) as device_id
|from all_clk_diary_card oc inner join device_id_new
|on oc.device_id = device_id_new.device_id
""".stripMargin
)
new_clk_device.createOrReplaceTempView("new_clk_device")
//3.当天老用户数
val old_count = sc.sql( //2.当天新用户中的点击用户数
s""" // val new_clk_count = sc.sql(
|select '${stat_date}' as stat_date,count(distinct(dio.device_id)) as old_count // s"""
|from device_id_old dio left join agency_id // |select '${stat_date}' as stat_date,count(distinct(oc.device_id)) as new_clk_count
|on dio.device_id = agency_id.device_id // |from all_clk_diary_card oc inner join device_id_new
|where agency_id.device_id is null // |on oc.device_id = device_id_new.device_id
""".stripMargin // """.stripMargin
) // )
////2.1 有点击的新用户
//4.当天新用户数 // val new_clk_device = sc.sql(
val new_count = sc.sql( // s"""
s""" // |select distinct(oc.device_id) as device_id
|select '${stat_date}' as stat_date,count(distinct(din.device_id)) as new_count // |from all_clk_diary_card oc inner join device_id_new
|from device_id_new din left join agency_id // |on oc.device_id = device_id_new.device_id
|on din.device_id = agency_id.device_id // """.stripMargin
|where agency_id.device_id is null // )
""".stripMargin // new_clk_device.createOrReplaceTempView("new_clk_device")
) //
//
//5.有点击老用户的曝光数 // //3.当天老用户数
val exp_clkold_count = sc.sql( //
s""" // val old_count = sc.sql(
|select '${stat_date}' as stat_date,count(dp.device_id) as imp_clkold_count // s"""
|from data_feed_exposure_precise dp inner join old_clk_device // |select '${stat_date}' as stat_date,count(distinct(dio.device_id)) as old_count
|on dp.device_id = old_clk_device.device_id // |from device_id_old dio left join agency_id
|where stat_date='${stat_date}' // |on dio.device_id = agency_id.device_id
|group by stat_date // |where agency_id.device_id is null
""".stripMargin // """.stripMargin
) // )
//
//6.有点击新用户的曝光数 // //4.当天新用户数
val exp_clknew_count = sc.sql( // val new_count = sc.sql(
s""" // s"""
|select '${stat_date}' as stat_date,count(dp.device_id) as imp_clknew_count // |select '${stat_date}' as stat_date,count(distinct(din.device_id)) as new_count
|from data_feed_exposure_precise dp inner join new_clk_device // |from device_id_new din left join agency_id
|on dp.device_id = new_clk_device.device_id // |on din.device_id = agency_id.device_id
|where stat_date='${stat_date}' // |where agency_id.device_id is null
|group by stat_date // """.stripMargin
""".stripMargin // )
) //
// //5.有点击老用户的曝光数
val result = old_clk_count.join(new_clk_count,"stat_date") // val exp_clkold_count = sc.sql(
.join(old_count,"stat_date") // s"""
.join(new_count,"stat_date") // |select '${stat_date}' as stat_date,count(dp.device_id) as imp_clkold_count
.join(exp_clkold_count,"stat_date") // |from data_feed_exposure_precise dp inner join old_clk_device
.join(exp_clknew_count,"stat_date") // |on dp.device_id = old_clk_device.device_id
// |where stat_date='${stat_date}'
GmeiConfig.writeToJDBCTable(result, "device_clk_imp_reason", SaveMode.Append) // |group by stat_date
// """.stripMargin
// )
//
// //6.有点击新用户的曝光数
// val exp_clknew_count = sc.sql(
// s"""
// |select '${stat_date}' as stat_date,count(dp.device_id) as imp_clknew_count
// |from data_feed_exposure_precise dp inner join new_clk_device
// |on dp.device_id = new_clk_device.device_id
// |where stat_date='${stat_date}'
// |group by stat_date
// """.stripMargin
// )
//
// val result = old_clk_count.join(new_clk_count,"stat_date")
// .join(old_count,"stat_date")
// .join(new_count,"stat_date")
// .join(exp_clkold_count,"stat_date")
// .join(exp_clknew_count,"stat_date")
//
// GmeiConfig.writeToJDBCTable(result, "device_clk_imp_reason", SaveMode.Append)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment