|SELECT '${stat_date}' as stat_date,sum(a.time_all)/count(a.device_id) as device_duration_avge,count(distinct(a.device_id)) as device_num
|from
|(select device_id,sum(params['duration']) as time_all
|from bl.bl_alpha_et_mg_maidianlog_inc_d
|where type='on_app_session_over'
|and partition_day='${partition_date}'
|GROUP BY device_id) a
|select '${stat_date}' as stat_date,count(DISTINCT(device_id))
|from ML_ALPHA_C_CT_DV_DEVICE_DIMEN_D
|where partition_day='${partition_date}'
|and is_today_active="1"
""".stripMargin
)
device_duration_avge.show()
device_num_count.show()
valduration_everytime_avge=sc.sql(
valduration_device=sc.sql(
s"""
|SELECT '${stat_date}' as stat_date,sum(a.time_duration)/count(a.device_id) as duration_everytime_avge from (select device_id,params['duration'] as time_duration
|from bl.bl_alpha_et_mg_maidianlog_inc_d
|where type='on_app_session_over'
|and partition_day='${partition_date}') a
|select '${stat_date}' as stat_date,sum(user_duration)/count(DISTINCT(device_id))