我正在尝试使用 Workflows 和 Cloud Scheduler 安排 Dataform 执行,如 here.
所记录具体来说,我正在尝试自定义 Dataform 工作流调用请求,以便仅执行那些带有“每小时”标签的模型,这部分记录在here.
我得到的 YAML 是:
main:
steps:
- init:
assign:
- repository: projects/XXXXX/locations/europe-west4/repositories/XXXXX
- createCompilationResult:
call: http.post
args:
url: ${"https://dataform.googleapis.com/v1beta1/" + repository + "/compilationResults"}
auth:
type: OAuth2
body:
compilationResult: ${compilationResult.body.name}
invocationConfig:
includedTags:
- hourly
transitiveDependenciesIncluded: true
result: compilationResult
- createWorkflowInvocation:
call: http.post
args:
url: ${"https://dataform.googleapis.com/v1beta1/" + repository + "/workflowInvocations"}
auth:
type: OAuth2
body:
compilationResult: ${compilationResult.body.name}
result: workflowInvocation
- complete:
return: ${workflowInvocation.body.name}
但是当我尝试部署此工作流程时出现此错误:
无法部署工作流:构建失败:步骤错误 createCompilationResult:键“body”的错误评估属性: 键“compilationResult”的错误评估属性:符号 'compilationResult.body.invocationConfig' 未定义,符号 'compilationResult.body' 未定义,符号 'compilationResult' 既不是变量也不是子工作流名称(代码:3)
我对如何解决这个问题没有太多经验。我只是在关注链接的文档,显然我遗漏了一些东西或者文档是错误的。
你知道怎么解决吗?
我认为文档是错误的。我得到了我想要的,但没有遵循文档的建议here:文档建议:
用以下代码替换createCompilationResult主体 片段...
但我实际上在 createWorkflowInvocation 中替换了相同的代码片段,只是因为它更有意义......并且它按我预期的那样工作。我认为文档中存在复制/粘贴问题,从上一节复制并粘贴到这一节。
我正在分享正确的 YAML(至少对我有用):
main:
steps:
- init:
assign:
- repository: projects/XXXXX/locations/europe-west4/repositories/XXXXX
- createCompilationResult:
call: http.post
args:
url: ${"https://dataform.googleapis.com/v1beta1/" + repository + "/compilationResults"}
auth:
type: OAuth2
body:
gitCommitish: main
result: compilationResult
- createWorkflowInvocation:
call: http.post
args:
url: ${"https://dataform.googleapis.com/v1beta1/" + repository + "/workflowInvocations"}
auth:
type: OAuth2
body:
compilationResult: ${compilationResult.body.name}
invocationConfig:
includedTags:
- hourly
transitiveDependenciesIncluded: true
result: workflowInvocation
- complete:
return: ${workflowInvocation.body.name}