Informatica Cloud:删除有条件的重复项

Informatica Cloud : remove duplicate with condition

我有一个从源中删除一些行的请求。 此源包含 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单行,取现值

其他: 如果存在相同 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 泽维尔

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

请查找可以转换为 informatica 地图的查询。

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;