Commit 086bdafe authored by 王志伟's avatar 王志伟

explore

parent baf43ce9
package com.gmei
import java.io.Serializable
import java.text.SimpleDateFormat
import java.util.Calendar
import com.gmei.WeafareStat.{defaultParams, parser}
import org.apache.spark.sql.{SaveMode, TiContext}
......@@ -51,18 +53,27 @@ object testt {
val strategies = Seq("3$","4$","5$","6$","7$","8$","c$","d$","e$","A$","B$","C$","D$")
for (strategy <- strategies){
println(strategy)
val get_data_dura = sc.sql(
s"""
|select partition_date, sum(params['duration']) as total_dur,count(distinct(cl_id)) as num
|from online.tl_hdfs_maidian_view
|where action="on_app_session_over"
|and cl_id regexp'${strategy}'
|and params['duration']>=0 and params['duration']<86400
|and partition_date >='20180801'
|group by partition_date order by partition_date desc
for(i <- 1 to 10){
val cal = Calendar.getInstance
cal.add(Calendar.DATE, -i)
//设置时间格式
val time = cal.getTime
//将时间格式套用在获取的时间戳上
val newtime: String = new SimpleDateFormat("yyyy-MM-dd").format(time)
println(newtime)
val get_data_dura = sc.sql(
s"""
|select params
|from online.tl_hdfs_maidian_view
|where action="on_app_session_over"
|and cl_id regexp'${strategy}'
|and params['duration']>=0 and params['duration']<86400
|and partition_date = ${newtime}
""".stripMargin
)
get_data_dura.show()
)
get_data_dura.show()
}
}
......
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