sql_pred = """
select
k.record_time,
k.predict_datetime,
k.object_code,
sum(k.predict_value) AS area_pred_qty
from
(select
record_time,
predict_datetime,
object_code,
predict_value,
product_type
from
dm_predict.region_predict_result
where
task_type = 'pickup'
and substr(record_time, 1, 10) = '2021-09-27'
and predict_datetime in ('2021-10-01','2021-10-02')) k
group by record_time,predict_datetime,object_code
"""
DF_pred = spark.sql(sql_pred)
DF_pred.createOrReplaceTempView("DF_pred_qty")
'''select
k.area_code,k.type_date,k.type,k.income_code,
sum(k.qty) AS area_pred_qty
from
(select
object_code as area_code,
predict_datetime as type_date,
task_type as type,
product_type as income_code,
predict_value as qty,
predict_period
from
dm_predict.region_predict_result
where
inc_day in ('20211101',
'20211102',
'20211103',
'20211104',
'20211105',
'20211106',
'20211107',
'20211108',
'20211109',
'20211110',
'20211111',
'20211112',
'20211113',
'20211114',
'20211115',
'20211116',
'20211117',
'20211118',
'20211119',
'20211120',
'20211121',
'20211122',
'20211123',
'20211124',
'20211125',
'20211126',
'20211127',
'20211128',
'20211129',
'20211025',
'20211026',
'20211027',
'20211028',
'20211029',
'20211030')
and predict_period = '1D') k
group by k.area_code,k.type_date,k.type,k.income_code'''
#-----------------------------------------------------------------------------------------------------------------
sql_real = """
select
k.days,
k.area_code,
sum(k.all_quantity) area_real_qty_yesterday
from
(
select
income_code,
area_code,
all_quantity,
days
from
dm_ordi_predict.static_area_org
where
inc_day <= '20210927'
and inc_day >= '20210901'
and type = 'pickup'
) k
group by
days,
area_code
"""
DF_real = spark.sql(sql_real)
DF_real.createOrReplaceTempView("DF_real_qty")
sql_real = """
select
k.days,
k.area_code,
sum(k.all_quantity) area_real_qty_yesterday
from
(
select
income_code,
area_code,
all_quantity,
days
from
dm_ordi_predict.static_area_org
where
inc_day <= '{0}'
and inc_day >= '{1}'
and type = 'pickup'
) k
group by
days,
area_code
""".format(today,before)
# 区分产品板块,收/派的版本 #############################
'''select
k.days,
k.area_code,
k.income_code,
k.type,
sum(k.all_quantity) area_real_qty
from
(
select
income_code,
type,
all_quantity,
days,
area_code
from
dm_ordi_predict.static_area_org
where
inc_day <= '20201126'
and inc_day >= '20201026'
) k
group by
income_code,
type,
days,
area_code
'''
#-----------------------------------------------------------------------------------------------------------------
sql_batch_qty = """
select
actual_arrive_votes as batch_real_qty,
batch_code,
inc_day
FROM
dm_ops.pass_forecast_batch_monitor_dtl
where
inc_day between '20210901' and '20210927'
"""
DF_batch_qty = spark.sql(sql_batch_qty)
DF_batch_qty.createOrReplaceTempView("DF_batch_qty")
# 检查数据是否全
'''select
count(*) as a
from
(
select
distinct inc_day
from
(
select
actual_arrive_votes as batch_real_qty,
batch_code,
inc_day
FROM
dm_ops.pass_forecast_batch_monitor_dtl
where
inc_day <= '20201121'
and inc_day >= '20201030'
) g
) d'''
Hya-sql-memo
需积分: 5 39 浏览量
2023-04-14
13:51:26
上传
评论
收藏 26KB ZIP 举报
萌甘薯
- 粉丝: 1
- 资源: 4
最新资源
- 水稻病害基于Yolov8算法优化目标检测识别与AI辅助决策python源码+模型+使用说明.zip
- 海尔618算价表_七海5.20_16.00xlsx(1)(2).xlsx
- WebCrawler.scr
- 【计算机专业毕业设计】大学生就业信息管理系统设计源码.zip
- YOLO 数据集:8种路面缺陷病害检测【包含划分好的数据集、类别class文件、数据可视化脚本】
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于YOLOv8的FPS TPS AI自动锁定源码+使用步骤说明.zip
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于yolov8+streamlit的火灾检测部署源码+模型.zip
- 测试aaaaaaabbbbb
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈