metafacture / metafacture-core

Core package of the Metafacture tool suite for metadata processing.
https://metafacture.org
Apache License 2.0
69 stars 34 forks source link

lookup as filter #372

Closed TobiasNx closed 2 years ago

TobiasNx commented 3 years ago

At the moment lookup maps matching values and passes through values that do not match. While there is a way to set a default value for all not matching values it would be nice to use the lookup as optional filter too so that only mapped values will be passed on.

At the moment:

Input litA: cat, litA: dog, litA: dragon

<data source="litA">
  <lookup>
    <entry name="cat" value=" mammal"/>
    <entry name="dog" value=" mammal"/>
  </lookup>
</data>

Output: litA: mammal, litA: mammal, litA: dragon

If used with the option filter. litA: dragon should be ignored.

blackwinter commented 2 years ago

Are you sure that litA: dragon is actually emitted? That's exactly what the test org.metafacture.metamorph.functions.LookupTest.shouldLookupValuesInLocalMap covers, isn't it? 1: b is not emitted there.

This is also consistent with the implementation in org.metafacture.metamorph.api.helpers.AbstractSimpleStatelessFunction: processedValue is not emitted if it's null, which is the default value in org.metafacture.metamorph.functions.Lookup unless otherwise specified.

blackwinter commented 2 years ago

Can this issue be clarified - or closed if obsolete?

fsteeg commented 2 years ago

Are you sure that litA: dragon is actually emitted? That's exactly what the test [...] covers, isn't it?

See also this sample in the playground.

TobiasNx commented 2 years ago

I think this can be closed.