Commit a1f1538e by chenyuanjie

fix

parent bd92c00a
...@@ -58,21 +58,14 @@ if __name__ == '__main__': ...@@ -58,21 +58,14 @@ if __name__ == '__main__':
start_day = str(start_day).replace("-", "") start_day = str(start_day).replace("-", "")
end_day = str(end_day).replace("-", "") end_day = str(end_day).replace("-", "")
print(f"{date_info}的月初是:{start_day},月末是:{end_day}") print(f"{date_info}的月初是:{start_day},月末是:{end_day}")
if date_type == 'us':
sql = f""" year_int = int(year_str)
create table if not exists {export_tb} (
like {export_master_tb} including defaults including comments
);
delete from {export_tb} where report_date >= '{start_day}' and report_date <= '{end_day}'
"""
else:
sql = f""" sql = f"""
create table if not exists {export_tb} ( CREATE TABLE IF NOT EXISTS {export_tb}
like {export_master_tb} including defaults including comments PARTITION OF {export_master_tb}
); FOR VALUES FROM ('{year_int}-01-01') TO ('{year_int + 1}-01-01');
delete from {export_tb} where report_date > '{start_day}' and report_date <= '{end_day}' DELETE FROM {export_master_tb} WHERE report_date >= '{start_day}' AND report_date <= '{end_day}'
""" """
DBUtil.engine_exec_sql(pg_clu_engine, sql) DBUtil.engine_exec_sql(pg_clu_engine, sql)
# 导出表名 # 导出表名
...@@ -80,7 +73,7 @@ if __name__ == '__main__': ...@@ -80,7 +73,7 @@ if __name__ == '__main__':
site_name=site_name, site_name=site_name,
db_type=db_type, db_type=db_type,
hive_tb="dwd_buyer_st", hive_tb="dwd_buyer_st",
export_tb=export_tb, export_tb=export_master_tb,
col=[ col=[
"search_term", "search_term",
"report_date", "report_date",
......
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