Informatica Cloud:删除条件重复

时间:2017-02-22 09:17:51

标签: duplicates cloud informatica

我有一个请求从源中删除一些行。 此源包含3列:Id,Type,Value,并包含一些数据,如:

Id    Type    Value
1     Master  This is the first value
1     Second  This is a new value
1     Third   This is not a mandatory value
2     Master  Another one
2     Third   And again
3     Second  A new hope
3     Third   A third
4     Second  A single value
...

保持行的规则是:

如果一行为单行,则获取现有值

其他: 如果存在相同Id和“Master”的多行,请获取“Master”值

如果同一Id和'Master'的多行不存在且'Second'存在,请获取'Second'值

如果同一Id和'Master'的多行不存在且'Second'不存在且'Third'存在,则获取'Third'值。

在我的样本中,我只想提取:

Id  Type    Value
1   Master  This is the first value
2   Master  Another one
3   Second  A new hope
4   Second  A single value

我尝试拆分为3个不同的来源并加入或查找,但没有找到任何参数来丢弃重复的行。

我怎么能这样做?

提前致谢, BR 泽维尔

2 个答案:

答案 0 :(得分:0)

尝试通过分拣机将它们按ID排序然后输入,最后通过ID asc,desc的聚合器分组,具体取决于您的要求(幸运大师在第二个按字母顺序排在第三之前)

答案 1 :(得分:0)

请找到可以转换为informatica map的查询。

create table test1
( id integer,
  type varchar2(100),
  value varchar2(1000)
);

insert into  test1 values (1,'Master','This is the first value');
insert into  test1 values (1,'Second','This is a new value');
insert into  test1 values (1,'Third','This is not a mandatory value');
insert into  test1 values (2,'Master','This is the first value');
insert into  test1 values (2,'Third','This is not a mandatory value');
insert into  test1 values (3,'Second','This is the first value');
insert into  test1 values (3,'Third','This is not a mandatory value');
insert into  test1 values (4,'Second','mandatory value');
commit;

select * from test1;    

From the below query "agg" part can be done in aggregator and decode function within aggregator transformation.

Then use joiner to join agg part and actual table

use filter to filter the required rows

  with agg as
     (select        max(case when type='Master' then 10 
                when type='Second' then 9
                when type='Third' then 8
                else 7 end) ms,

            id
      from test1
     group by id

  ) 
     select a.ms,b.* from agg a, test1 b
        where a.id=b.id
         and case when a.ms=10 then 'Master' 
                 when a.ms=9 then 'Second'
                  when a.ms=8 then 'Third'
                   else 'noval2'
                  end =b.type;