我尝试通过Go应用程序从现有模板启动Dataflow作业。
到目前为止,我已带来了CreateJobFromTemplateRequest
并创建了一份包含工作信息的Try it this will work definitely:
Let's take a sample example:
For example, create a sample table
CREATE TABLE bob (
empno VARCHAR2(10) NOT NULL,
ename VARCHAR2(15) NOT NULL,
ssn VARCHAR2(10) NOT NULL);
Insert data into that table
Insert into bob ( empno,ename,ssn) values ('abC0123458','zXe5378023','0pl4783202');
Insert into bob ( empno,ename,ssn) values ('0123abcdef','a12dldfddd','Rns0101010');
Query to select the all the columns
select * from bob
where length(trim(translate(substr(empno,1,3),'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',' '))) IS NULL
AND
length(trim(translate(substr(empno,4,4),'0123456789',' '))) IS NULL;
To do the same thing on multiple columns use union operator
select * from bob
where length(trim(translate(substr(empno,1,3),'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',' '))) IS NULL
AND
length(trim(translate(substr(empno,4,4),'0123456789',' '))) IS NULL;
union
select * from bob
where length(trim(translate(substr(ename,1,3),'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',' '))) IS NULL
AND
length(trim(translate(substr(ename,4,4),'0123456789',' '))) IS NULL;
。
我现在如何使用Compute Engine中的内置服务帐户凭据执行该请求?
答案 0 :(得分:2)
仅在为您正在呼叫的服务开发Auto-generated Google APIs for Go时才建议使用Google Client Library for Go。 Dataflow还没有客户端库。
使用默认凭据从Go应用启动数据流模板:
ctx := context.Background()
oauthClient, err := google.DefaultClient(ctx, dataflow.CloudPlatformScope)
dataflowService, err := dataflow.New(oauthClient)
if err != nil {
panic(err)
}
templateRequest := dataflow.CreateJobFromTemplateRequest{
GcsPath: "gcs path to template here",
JobName: "choose a unique job name here",
Parameters: map[string]string{
"parameters": "for job",
},
}
result, err := dataflowService.Projects.Templates.Create("project id", &templateRequest).Do()
if err != nil {
panic(err)
}