我有两个带有一个公共字段的文件,基于这个字段值,我需要获得第二个文件值。
我该如何在这里添加where条件?
是否有其他管道可供不使用?
File1:
tcno,date,amt
1234,3/10/2016,1000
1234,3/11/2016,400
23456,2/10/2016,1500File2:
cno,fname,lname,city,phone,mail
1234,first,last,city,1234556,123@123.com示例代码:
Pipe pipe1 = new Pipe("custPipe");
Pipe pipe2 = new Pipe("tscnPipe");
Fields cJoinField = new Fields("cno");
Fields tJoinField = new Fields("tcno");
Pipe pipe = new HashJoin(pipe1, cJoinField, pipe2, tJoinField, new OuterJoin());
//HOW TO ADD WHERE CONDITION i.e. CNO IS NULL FROM SECOND FILE
Fields outFields = new Fields("tcno","tdate", "tamt");我期望输出作为第一文件,最后一行23456,2/10/2016,1500
发布于 2016-04-01 08:07:05
根据代码中的注释:
//HOW TO ADD WHERE CONDITION i.e. CNO IS NULL FROM SECOND FILE尝试使用FilterNull。
在HashJoin步骤之后,在代码中添加以下行:
FilterNull filterNull = new FilterNull();
pipe = new Each( pipe, cJoinField, filterNull );类似于:
Pipe pipe1 = new Pipe("custPipe");
Pipe pipe2 = new Pipe("tscnPipe");
Fields cJoinField = new Fields("cno");
Fields tJoinField = new Fields("tcno");
Pipe pipe = new HashJoin(pipe1, cJoinField, pipe2, tJoinField, new OuterJoin());
// Filter out those tuples which has cno as null
FilterNull filterNull = new FilterNull();
pipe = new Each( pipe, cJoinField, filterNull );
Fields outFields = new Fields("tcno","tdate", "tamt");https://stackoverflow.com/questions/36199203
复制相似问题