Gcloud 主题在 Apache Beam 中转义
Gcloud topic escaping in 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"
但我收到一条错误消息:
错误:(gcloud.beta.dataflow.jobs.run) 参数 --parameters:dict arg 的错误语法:[b.salary]。如果您想了解有关转义列表或字典标志值的信息,请参阅 gcloud topic escaping
。
我看到了 gcloud 主题转义的文档,但不知道如何应用它 here.Can 请有人帮助我。
谢谢。
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"
在实际模板上(由google提供):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"
这个 returns INVALID_ARGUMENT: (bf23ae8a2a6f1efe): The workflow could not be created. Causes: (bf23ae8a2a6f165b): Found unexpected parameters: ['query' (perhaps you meant 'runner')]
,这表明 我们确实解决了问题 :数据流正确理解我们正在传递一个 query
范围。但是 google 模板没有使用这样的参数,因此会抛出一个错误,这是预期的行为。
非常感谢。对于仍然感到困惑的任何人,这里有一个包含多个元素的示例。分隔符是 ~
gcloud dataflow jobs run <INPUT> \
--gcs-location=gs://dataflow-templates-us-central1/latest/Jdbc_to_BigQuery \
--region=northamerica-northeast1 \
--network=<INPUT> \
--subnetwork=<INPUT> \
--parameters ^~^driverClassName=com.mysql.jdbc.Driver~driverJars="<INPUT>"~connectionProperties="<INPUT>"~outputTable="<INPUT>"~password="<INPUT>"~username="<INPUT>"~bigQueryLoadingTemporaryDirectory="<INPUT>"~connectionURL="<INPUT>"~query="select name, age, location from testtable"
我正在尝试通过 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"
但我收到一条错误消息:
错误:(gcloud.beta.dataflow.jobs.run) 参数 --parameters:dict arg 的错误语法:[b.salary]。如果您想了解有关转义列表或字典标志值的信息,请参阅 gcloud topic escaping
。
我看到了 gcloud 主题转义的文档,但不知道如何应用它 here.Can 请有人帮助我。
谢谢。
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"
在实际模板上(由google提供):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"
这个 returns INVALID_ARGUMENT: (bf23ae8a2a6f1efe): The workflow could not be created. Causes: (bf23ae8a2a6f165b): Found unexpected parameters: ['query' (perhaps you meant 'runner')]
,这表明 我们确实解决了问题 :数据流正确理解我们正在传递一个 query
范围。但是 google 模板没有使用这样的参数,因此会抛出一个错误,这是预期的行为。
非常感谢。对于仍然感到困惑的任何人,这里有一个包含多个元素的示例。分隔符是 ~
gcloud dataflow jobs run <INPUT> \
--gcs-location=gs://dataflow-templates-us-central1/latest/Jdbc_to_BigQuery \
--region=northamerica-northeast1 \
--network=<INPUT> \
--subnetwork=<INPUT> \
--parameters ^~^driverClassName=com.mysql.jdbc.Driver~driverJars="<INPUT>"~connectionProperties="<INPUT>"~outputTable="<INPUT>"~password="<INPUT>"~username="<INPUT>"~bigQueryLoadingTemporaryDirectory="<INPUT>"~connectionURL="<INPUT>"~query="select name, age, location from testtable"