数据流模板中的动态 BigQuery 查询
Dynamic bigquery query in dataflow template
我编写了一个 Dataflow 作业,当我手动 运行 它时效果很好。这是相关部分(为清楚起见删除了一些验证代码):
parser.add_argument('--end_datetime',
dest='end_datetime')
known_args, pipeline_args = parser.parse_known_args(argv)
query = <redacted SQL String with a placeholder for a date>
query = query.replace('#ENDDATETIME#', known_args.end_datetime)
with beam.Pipeline(options=pipeline_options) as p:
rows = p | 'read query' >> beam.io.Read(beam.io.BigQuerySource(query=query, use_standard_sql=True))
现在我想创建一个模板并使用动态 ENDDATETIME 定期将其安排到 运行。据我了解,为了做到这一点,我需要根据此文档将 add_argument 更改为 add_value_provider_argument:
https://cloud.google.com/dataflow/docs/templates/creating-templates
不幸的是,当我需要它们时,ValueProvider 值似乎不可用,它们仅在管道本身内部可用。 (如果我在这里错了,请纠正我......)。所以我有点卡住了。
有人对我如何在数据流模板中的查询中获取动态日期有任何指示吗?
Python 目前仅支持 FileBasedSource IOs 的 ValueProvider 选项。您可以通过单击您使用的 link 处的 Python 选项卡来查看:
https://cloud.google.com/dataflow/docs/templates/creating-templates
在 "Pipeline I/O and runtime parameters" 部分下。
我编写了一个 Dataflow 作业,当我手动 运行 它时效果很好。这是相关部分(为清楚起见删除了一些验证代码):
parser.add_argument('--end_datetime',
dest='end_datetime')
known_args, pipeline_args = parser.parse_known_args(argv)
query = <redacted SQL String with a placeholder for a date>
query = query.replace('#ENDDATETIME#', known_args.end_datetime)
with beam.Pipeline(options=pipeline_options) as p:
rows = p | 'read query' >> beam.io.Read(beam.io.BigQuerySource(query=query, use_standard_sql=True))
现在我想创建一个模板并使用动态 ENDDATETIME 定期将其安排到 运行。据我了解,为了做到这一点,我需要根据此文档将 add_argument 更改为 add_value_provider_argument:
https://cloud.google.com/dataflow/docs/templates/creating-templates
不幸的是,当我需要它们时,ValueProvider 值似乎不可用,它们仅在管道本身内部可用。 (如果我在这里错了,请纠正我......)。所以我有点卡住了。
有人对我如何在数据流模板中的查询中获取动态日期有任何指示吗?
Python 目前仅支持 FileBasedSource IOs 的 ValueProvider 选项。您可以通过单击您使用的 link 处的 Python 选项卡来查看: https://cloud.google.com/dataflow/docs/templates/creating-templates
在 "Pipeline I/O and runtime parameters" 部分下。