Commit 1799f3a4 authored by Pengfei Xue's avatar Pengfei Xue

dont group by app version

parent 4e10f4e5
......@@ -2,3 +2,4 @@
run.sh
*.log
target/
.idea/
......@@ -27,33 +27,35 @@ object actionCheck {
val df = sc.sql(
s"""
|select
| a.partition_date as today,
| a.partition_date as date,
| b.partition_date as yesterday,
| a.cl_type,
| a.app_version,
| a.action,
| a.c as todayCount,
| b.c as yesterdayCount,
| case when b.c = 0 then 1.0 else (a.c - b.c) * 1.0 / b.c end as chainRate
|from
|(
| select partition_date, cl_type, app_version, action, count(1) as c
| select partition_date, cl_type, action, count(1) as c
| from online.bl_hdfs_maidian_updates
| where partition_date = '${partition_date}'
| group by partition_date, cl_type, app_version, action
| group by partition_date, cl_type, action
|) a left join (
| select partition_date, cl_type, app_version, action, count(1) as c
| select partition_date, cl_type, action, count(1) as c
| from online.bl_hdfs_maidian_updates
| where partition_date = '${yesterday}'
| group by partition_date, cl_type, app_version, action
|) b on a.cl_type = b.cl_type and a.app_version = b.app_version and a.action = b.action
| group by partition_date, cl_type, action
|) b on a.cl_type = b.cl_type and a.action = b.action
""".stripMargin)
// write out to tidb
Class.forName("com.mysql.jdbc.Driver")
val prop= new java.util.Properties()
prop.put("user", "root")
prop.put("password", "3SYz54LS9#^9sBvC")
val url="jdbc:mysql://172.16.40.172:4000/jerry_test"
prop.put("driver", "com.mysql.jdbc.Driver")
val url="jdbc:mysql://172.16.40.172:4000/jerry_test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true"
//df is a dataframe contains the data which you want to write.
df.write.mode(SaveMode.Append).jdbc(url,"maidian_action_check", prop)
}
......
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