Pie*_*dre 1 google-bigquery google-cloud-platform google-workflows
我计划有一个云调度程序,每天早上 8 点调用 GCP 工作流程。我的 GCP 工作流程将有大约 15 个不同的工作流程steps
,并且仅在 BigQuery 上进行转换(更新、删除、添加)。有些查询会很长,我想知道是否有办法将.sql
文件加载到 GCP 工作流程中task1.yaml
?
#workflow entrypoint
ProcessItem:
params: [project, gcsPath]
steps:
- initialize:
assign:
- dataset: wf_samples
- input: ${gcsPath}
- sqlQuery: QUERY HERE
...
Run Code Online (Sandbox Code Playgroud)
你需要做类似的事情:(当然你可以将其分配给像这样的变量input
)
#workflow entrypoint
main:
steps:
- getSqlfile:
call: http.get
args:
url: https://raw.githubusercontent.com/jisaw/sqlzoo-solutions/master/select-in-select.sql
headers:
Content-Type: "text/plain"
result: queryFromFile
- final:
return: ${queryFromFile.body}
Run Code Online (Sandbox Code Playgroud)
对于云存储,可能如下所示:
call: http.get
args:
url: https://storage.cloud.google.com/................./q1.sql
headers:
Content-Type: "text/plain"
auth:
type: OIDC
result: queryFromFile
Run Code Online (Sandbox Code Playgroud)
或具有此格式的事件(不同的 URL 语法 + OAuth2)
call: http.get
args:
url: https://storage.googleapis.com/................./q1.sql
headers:
Content-Type: "text/plain"
auth:
type: OAuth2
result: queryFromFile
Run Code Online (Sandbox Code Playgroud)
确保调用者具有访问 Cloud Storage 文件的正确权限。
注意:在进一步测试中,为了正确工作,
text/plain
必须在 GCS 文件上设置 mime-type。
归档时间: |
|
查看次数: |
1164 次 |
最近记录: |