Gcloud 主题在 Apache Beam 中转义

ris*_*097 2 google-cloud-dataflow apache-beam

我正在尝试通过 gcloud 命令运行数据流作业:

gcloud beta dataflow jobs run test --gcs-location gs://bucket/templates/templateName --parameters query="select a.name,b.salary,a.id from table1 a join table2 b on a.id = b.id"
Run Code Online (Sandbox Code Playgroud)

但我收到一条错误消息:

错误:(gcloud.beta.dataflow.jobs.run) 参数 --parameters:dict arg 的错误语法:[b.salary]。请查看gcloud topic escaping您是否需要有关转义列表或字典标志值的信息。

我看到了 gcloud 主题转义的文档,但无法弄清楚如何在此处应用它。有人可以帮我解决这个问题。

谢谢。

The*_*der 5

parameters参数使用字典作为参数。如 中所述gcloud topic escaping,您需要在字典的元素之间指定一个分隔符,即使我们这里只有一个元素。

因此,我们可以给出一个任意的分隔符,如“:”,使用(注意之前的更改query=):

gcloud beta dataflow jobs run test --gcs-location gs://bucket/templates/templateName --parameters ^:^query="select a.name,b.salary,a.id from table1 a join table2 b on a.id = b.id"


在实际模板上(由谷歌提供): gcloud beta dataflow jobs run test --gcs-location=gs://dataflow-templates/wordcount/template_file --parameters ^:^query="select a.name,b.salary,a.id from table1 a join table2 b on a.id = b.id"

这返回INVALID_ARGUMENT: (bf23ae8a2a6f1efe): The workflow could not be created. Causes: (bf23ae8a2a6f165b): Found unexpected parameters: ['query' (perhaps you meant 'runner')],这表明我们确实解决了问题:数据流正确理解我们正在传递query参数。但是 google 模板不使用此类参数,因此会引发错误,这是预期的行为。