Commit 44df8802 authored by litaolemo's avatar litaolemo

update

parent deb277df
......@@ -19,13 +19,15 @@ import sys
import time
from pyspark import SparkConf
from pyspark.sql import SparkSession, DataFrame
# from pyspark.sql.functions import lit
# import pytispark.pytispark as pti
db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
db='jerry_prod')
db='jerry_prod')
cursor = db.cursor()
def con_sql(sql):
# 从数据库的表里获取数据
......@@ -73,7 +75,6 @@ spark.sql("CREATE TEMPORARY FUNCTION json_map AS 'brickhouse.udf.json.JsonMapUDF
spark.sql("CREATE TEMPORARY FUNCTION is_json AS 'com.gmei.hive.common.udf.UDFJsonFormatCheck'")
spark.sql("CREATE TEMPORARY FUNCTION arrayMerge AS 'com.gmei.hive.common.udf.UDFArryMerge'")
task_list = []
task_days = 2
for t in range(1, task_days):
......@@ -219,7 +220,8 @@ left join
AND T.PAGE_CODE = 'search_result_welfare'
AND T.CARD_TYPE = 'common_card'
GROUP BY T.DEVICE_ID,
T.CARD_ID) C on T.DEVICE_ID=C.DEVICE_ID and T.CARD_ID = C.CARD_ID LEFT JOIN
T.CARD_ID) C on T.DEVICE_ID=C.DEVICE_ID and T.CARD_ID = C.CARD_ID
LEFT JOIN
(
SELECT T.DEVICE_ID,
T.DEVICE_OS_TYPE,
......@@ -234,15 +236,19 @@ left join
and (dev_view.device_id is null or dev_view.device_id='')
GROUP by D.DEVICE_OS_TYPE,
D.ACTIVE_TYPE
""".format(partition_day=yesterday_str,)
""".format(partition_day=yesterday_str, )
print(sql_search_ctr)
search_ctr_df = spark.sql(sql_search_ctr)
# spam_pv_df.createOrReplaceTempView("dev_view")
search_ctr_df.show(1)
sql_res = search_ctr_df.collect()
print("-------------------------------")
for res in sql_res:
print(res)
print("-------------------------------")
# for res in sql_res:
# # print(res)
# day_id = res.day_id
......@@ -283,4 +289,4 @@ and (dev_view.device_id is null or dev_view.device_id='')
# db.commit()
# print(res)
# # cursor.executemany()
db.close()
\ No newline at end of file
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