Commit 04a60449 authored by litaolemo's avatar litaolemo

update

parent 883cd047
......@@ -72,9 +72,9 @@ spark.sql("CREATE TEMPORARY FUNCTION is_json AS 'com.gmei.hive.common.udf.UDFJso
spark.sql("CREATE TEMPORARY FUNCTION arrayMerge AS 'com.gmei.hive.common.udf.UDFArryMerge'")
task_list = []
task_days = 2
task_days = 90
for t in range(1, task_days):
for t in range(0, task_days):
day_num = 0 - t
now = (datetime.datetime.now() + datetime.timedelta(days=day_num))
last_30_day_str = (now + datetime.timedelta(days=-30)).strftime("%Y%m%d")
......@@ -168,8 +168,8 @@ for t in range(1, task_days):
,t3.channel as channel
,NVL(t3.search_pv,0) as pv
,NVL(t3.search_uv,0) as uv
,if(NVL(t3.search_uv,0) <> 0 ,concat(cast((NVL(t4.hexin_card_click_pv,0)/NVL(t3.search_uv,0)) as decimal(18,2)),'') , '-') as search_core_pv
,if(NVL(t3.search_uv,0) <> 0 ,concat(cast((NVL(t4.neirong_card_click_pv,0)/NVL(t3.search_uv,0)) as decimal(18,2)),'') , '-') as search_pv
,if(NVL(t3.search_uv,0) <> 0 ,cast((NVL(t4.hexin_card_click_pv,0)/NVL(t3.search_uv,0)) as decimal(18,5)) , 0) as search_core_pv
,if(NVL(t3.search_uv,0) <> 0 ,cast((NVL(t4.neirong_card_click_pv,0)/NVL(t3.search_uv,0)) as decimal(18,5)) , 0) as search_pv
FROM
(--昨天总搜索量
SELECT partition_date,active_type,device_os_type,channel,search_pv,search_uv
......@@ -728,25 +728,25 @@ for t in range(1, task_days):
#
# finnal_df.show(1, False)
# sql_res = finnal_df.collect()
# for res in sql_res:
# # print(res)
# device_type = res.device_type
# active_type = res.active_type
# channel_type = res.channel_type
# core_pv_division_uv = res.core_pv_division_uv
# pv_division_uv = res.pv_division_uv
# pid = hashlib.md5(
# (today_str + device_type + active_type + channel_type).encode("utf8")).hexdigest()
# instert_sql = """replace into search_strategy_d(
# day_id,device_type,active_type,channel_type,core_pv_division_uv,pv_division_uv,pid
# ) VALUES('{day_id}','{device_type}','{active_type}','{channel_type}',{core_pv_division_uv},{pv_division_uv},'{pid}');""".format(
# day_id=today_str, device_type=device_type,
# active_type=active_type, channel_type=channel_type, core_pv_division_uv=core_pv_division_uv,pv_division_uv=pv_division_uv,pid=pid
#
# )
# print(instert_sql)
# # cursor.execute("set names 'UTF8'")
# res = cursor.execute(instert_sql)
# db.commit()
# print(res)
for res in sql_res:
# print(res)
device_type = res.device_os_type
active_type = res.active_type
channel_type = res.channel_type
core_pv_division_uv = res.search_core_pv
pv_division_uv = res.search_pv
pid = hashlib.md5(
(today_str + device_type + active_type + channel_type).encode("utf8")).hexdigest()
instert_sql = """replace into search_strategy_d(
day_id,device_type,active_type,channel_type,core_pv_division_uv,pv_division_uv,pid
) VALUES('{day_id}','{device_type}','{active_type}','{channel_type}',{core_pv_division_uv},{pv_division_uv},'{pid}');""".format(
day_id=today_str, device_type=device_type,
active_type=active_type, channel_type=channel_type, core_pv_division_uv=core_pv_division_uv,pv_division_uv=pv_division_uv,pid=pid
)
print(instert_sql)
# cursor.execute("set names 'UTF8'")
res = cursor.execute(instert_sql)
db.commit()
print(res)
db.close()
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