python-2.7 - 在数据流中循环 - 用于操作的 apache 束
问题描述
我在appache Beam中写了一个日常批处理操作的代码——数据流python代码。我正在尝试制作日期范围跑步者。即目前它昨天运行良好 - 如果我想从开始日期运行到结束日期它很困难。请求您为此建议任何方法。请找到我昨天运行的代码片段。
start_date = '20180101'
end_date = '20190101'
p = beam.Pipeline(options=options)
read = (
p
| 'BQRead: ' >> BQReader(
query=test_query.format(date=date))
)
transformed = (
read
| 'Transform 1 ' >> beam.ParDo(Transform1())
)
transformed | 'BQWrite' >> BQWriter(table + date, table_schema)
我尝试如下,但它不工作
start_date = datetime.strptime('20190101', "%Y%m%d")
end_date = datetime.strptime('20190110', "%Y%m%d")
dates = list(rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date))
for date in dates:
ds_nd = date.strftime('%Y%m%d')
p = beam.Pipeline(options=options)
read = (
p
| 'BQRead: ' >> BQReader(
query=test_query.format(date=ds_nd))
)
transformed = (
read
| 'Transform 1 ' >> beam.ParDo(Transform1())
)
transformed | 'BQWrite' >> BQWriter(table + ds_nd, table_schema)
解决方案
推荐阅读
- javascript - Rotativa 无法在视图中正确执行 jquery 脚本
- python - 针对不同训练数据表示的不同收敛(Numpy 数组和 TensorFlow Dataset API)
- python - 在给定两个端点列表的情况下选择整数子集
- c++ - C 和 C++ 标准对假设的三元硬件架构的适应性如何?
- node.js - 猫鼬填充排序_猫鼬Node.js
- flutter - 如何在flutter中实现短信检索api
- jquery - 克隆不起作用;多个脚本标签?
- qt - Qt 5.8 QTextEdit 文本光标颜色不会改变
- python - 替换文本中的数字
- javascript - 如何获取相同类名的每个值?