以同步方式通过云功能触发多个数据流作业?

时间:2017-10-10 12:47:59

标签: apache google-cloud-platform google-cloud-dataflow apache-beam

我必须使用Google Dataflow Process中的 const google = require('googleapis'); exports.goWithTheDataFlow = function(event, callback) { const file = event.data; if (file.resourceState === 'exists' && file.name) { google.auth.getApplicationDefault(function (err, authClient, projectId) { if (err) { throw err; } if (authClient.createScopedRequired && authClient.createScopedRequired()) { authClient = authClient.createScoped([ 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/userinfo.email' ]); } const dataflow = google.dataflow({ version: 'v1b3', auth: authClient }); dataflow.projects.templates.create({ projectId: 'testing1-180111', resource: { parameters: { }, jobName: 'cloud-fn-dataflow-test', gcsPath: 'gs://kishan-configuration/templates/FinalConfigTable' } }, function(err, response) { if (err) { console.error("problem running dataflow template, error was: ", err); } console.log("Dataflow template response: ", response); callback(); }); }); } }; 功能逐个触发多个模板。执行一个模板后,必须调用另一个模板。

package.json

{ "name": "kishan_kumar464", "version": "1.0.0", "main": "index.js", "dependencies": { "google-cloud": "^0.56.0", "googleapis": "^22.2.0" }, "devDependencies": {}, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Kishan", "license": "ISC", "description": "" } 文件代码是这个

declare @Table table(ID int identity(1,1), patient_date date)

insert into @Table values
 ('10/5/2017'),
 ('6/6/2017'),
 ('6/10/2017'),
 ('8/7/2017'),
 ('9/19/2017')

 select A.ID,
        A.patient_date,
        cast(B.patient_date as varchar(10)) + ' - ' + cast(A.patient_date as varchar(10)) as Period, --this column will show exactly what you asked
        abs(datediff(day,B.patient_date, A.patient_date)) as DaysDifference --this column is computed absolute difference in days between to dates
 from @Table A left join @Table B on A.ID = B.ID - 1

1 个答案:

答案 0 :(得分:0)

如果我理解正确,您希望从模板创建作业并等到完成。之后,您可以从模板创建下一个作业。正确的吗?

我认为您可以在创建作业后轮询作业状态(作业ID在dataflow.projects.templates.create的响应中。

要检查作业的状态,请使用projects.jobs.get API。