-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.py
26 lines (19 loc) · 974 Bytes
/
function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from googleapiclient.discovery import build
def trigger_df_job(cloud_event,environment):
service = build('dataflow', 'v1b3')
project = "prj-poc-001"
template_path = "gs://dataflow-templates-us-central1/latest/GCS_Text_to_BigQuery"
template_body = {
"jobName": "bq-load", # Provide a unique name for the job
"parameters": {
"javascriptTextTransformGcsPath": "gs://bkt-dataflow-metadata/udf.js",
"JSONPath": "gs://bkt-dataflow-metadata/bq.json",
"javascriptTextTransformFunctionName": "transform",
"outputTable": "prj-poc-001:cricket_dataset.icc_odi_batsman_ranking",
"inputFilePattern": "gs://bkt-ranking-data/batsmen_rankings.csv",
"bigQueryLoadingTemporaryDirectory": "gs://bkt-dataflow-metadata",
}
}
request = service.projects().templates().launch(projectId=project,gcsPath=template_path, body=template_body)
response = request.execute()
print(response)