首页 > 解决方案 > BigQuery SQL 作业对 Dataflow 管道的依赖性

问题描述

我在 python 中有一个 apache 光束管道,无论出于何种原因,它都有如下所示的流程。

client = bigquery.Client()
query_job1 = client.query('create table sample_table_1 as select * from table_1')  
result1 = query_job.result()

with beam.Pipeline(options=options) as p:

    records = (
            p
            | 'Data pull' >> beam.io.Read(beam.io.BigQuerySource(...))
            | 'Transform' >> ....
            | 'Write to BQ' >> beam.io.WriteToBigQuery(...)
    )

query_job2 = client.query('create table sample_table_2 as select * from table_2')  
result2 = query_job2.result()

SQL 作业 --> 数据管道 --> SQL 作业

当我在本地运行此序列时,此序列工作正常。但是,当我尝试将其作为 Dataflow 管道运行时,它并没有真正按此顺序运行。

有没有办法在数据流上运行时强制依赖?

标签: pythongoogle-cloud-dataflowapache-beam

解决方案


正如@PeterKim 提到的,您在评论部分描述的处理流程仅使用Dataflow 是不可能实现的。目前,Dataflow 编程模型不支持它。

您可以使用 Composer 来编排相互依赖的顺序作业执行,请点击此处


推荐阅读