Forum Discussion

philliperamos's avatar
philliperamos
Contributor
6 years ago

Omit missing fields in a Mapper

Hi community,

I would like to create a Master Mapper of sorts that will accept an input stream of let’s say field1 and field2, and just output those fields.

Mapper:
TEST_MasterMapper_2020_02_11.slp (4.9 KB)

I’ve uploaded a sample pipeline of what I would like to achieve.

Thanks everyone in advance!

3 Replies

  • dmiller's avatar
    dmiller
    Former Employee

    I’m trying to understand the ask. Are you saying you want a kind of universal Mapper configured to accept n number of fields, but if a field is not in the input, not to write that field to the output (instead of writing it with a null value)?

    • philliperamos's avatar
      philliperamos
      Contributor

      That’s correct.
      I essentially have 25+ data sets to extract from a source system, and from those data sets, there are about 50 common fields.
      Hence, a master mapper with the common fields, that will ignore the ‘missing’ fields.

      • cjhoward18's avatar
        cjhoward18
        Employee

        In your example pipeline given, if you enable the Null-safe access in the mapper, then attach another mapper at the end with the expression: $.filter((value, key) => value != null) mapped to the target: $ will give you all the values of your common mappings that are not null.