Commit 10337cb5 authored by litaolemo's avatar litaolemo

update

parent 6ee2b797
......@@ -132,8 +132,10 @@ for t in range(1, task_days):
print(quanzhong_dau_sql)
quanzhong_dau_df = spark.sql(quanzhong_dau_sql)
quanzhong_dau_df.createOrReplaceTempView("quanzhong_dau_view")
# quanzhong_dau_df.show(1)
# sql_res = quanzhong_dau_df.collect()
quanzhong_dau_df.show(1)
sql_res = quanzhong_dau_df.collect()
for res in sql_res:
print(res)
# DAU
DAU_sql = """
......@@ -164,8 +166,11 @@ for t in range(1, task_days):
print(DAU_sql)
dau_df = spark.sql(DAU_sql)
dau_df.createOrReplaceTempView("dau_view")
# dau_df.show(1)
# sql_res = dau_df.collect()
dau_df.show(1)
sql_res = dau_df.collect()
for res in sql_res:
print(res)
# CPT日均点击
cpc_daily_click_sql = r"""
SELECT partition_date,count(1) as pv
......@@ -183,8 +188,10 @@ group BY partition_date
print(cpc_daily_click_sql)
cpc_daily_click_df = spark.sql(cpc_daily_click_sql)
cpc_daily_click_df.createOrReplaceTempView("cpc_daily_click")
# cpc_daily_click_df.show(1)
# sql_res = cpc_daily_click_df.collect()
cpc_daily_click_df.show(1)
sql_res = cpc_daily_click_df.collect()
for res in sql_res:
print(res)
# 商详页PV
......@@ -256,8 +263,10 @@ group BY partition_date
print(bus_detail_sql)
bus_detail_df = spark.sql(bus_detail_sql)
bus_detail_df.createOrReplaceTempView("bus_detail")
# bus_detail_df.show(1)
# sql_res = bus_detail_df.collect()
bus_detail_df.show(1)
sql_res = bus_detail_df.collect()
for res in sql_res:
print(res)
# --cpc当日预算(有效口径)
......@@ -316,8 +325,10 @@ GROUP BY day_id
print(cpc_budget_sql)
cpc_budget_df = spark.sql(cpc_budget_sql)
cpc_budget_df.createOrReplaceTempView("cpc_budget")
# cpc_budget_df.show(1)
# sql_res = cpc_budget_df.collect()
cpc_budget_df.show(1)
sql_res = cpc_budget_df.collect()
for res in sql_res:
print(res)
# cpc收入、广告总消耗
cpc_income_sql = r"""
......@@ -347,24 +358,27 @@ group by partition_day
print(cpc_income_sql)
cpc_income_df = spark.sql(cpc_income_sql)
cpc_income_df.createOrReplaceTempView("cpc_income")
# cpc_income_df.show(1)
# sql_res = cpc_income_df.collect()
out_put_sql = """
SELECT bus_detail.referrer_search_welfare_pv / dau_view.dau as pv_div_dau,
bus_detail.referrer_search_welfare_pv / quanzhong_dau_view.quanzhong_dau as pv_div_quanzhong_dau,
(cpc_income.cpt_click_num + cpc_income.cpc_click_num) / bus_detail.referrer_search_welfare_pv as ad_flow_rat,
cpc_income.cpc_proportion_expend_amount/cpc_budget.budget as budget_consumption_rate,
cpc_income.cpc_proportion_expend_recharge_amount/cpc_income.cpc_click_num as cpc_item_pricing,
cpc_income.tol_proportion_expend_amount as tol_proportion_expend_amount
"""
out_df = spark.sql(out_put_sql)
# out_df.createOrReplaceTempView("out_df")
out_df.show(1)
sql_res = out_df.collect()
cpc_income_df.show(1)
sql_res = cpc_income_df.collect()
for res in sql_res:
print(res)
#
# out_put_sql = """
# select bus_detail.referrer_search_welfare_pv / dau_view.dau as pv_div_dau,
# bus_detail.referrer_search_welfare_pv / quanzhong_dau_view.quanzhong_dau as pv_div_quanzhong_dau,
# (cpc_income.cpt_click_num + cpc_income.cpc_click_num) / bus_detail.referrer_search_welfare_pv as ad_flow_rat,
# cpc_income.cpc_proportion_expend_amount/cpc_budget.budget as budget_consumption_rate,
# cpc_income.cpc_proportion_expend_recharge_amount/cpc_income.cpc_click_num as cpc_item_pricing,
# cpc_income.tol_proportion_expend_amount as tol_proportion_expend_amount
# """
# out_df = spark.sql(out_put_sql)
# # out_df.createOrReplaceTempView("out_df")
# out_df.show(1)
# sql_res = out_df.collect()
# for res in sql_res:
# print(res)
# for active_type in res_dict:
# db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
......
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