Skip to main content
Open

Simpler dynamic attribute mapping

Related products:Transformers
  • November 2, 2021
  • 1 reply
  • 14 views
siennaatsafe
danilo_fme
jdh
chriswilson
rdebliek
+1
  • siennaatsafe
    siennaatsafe
  • danilo_fme
    danilo_fme
  • jdh
    jdh
  • chriswilson
    chriswilson
  • rdebliek
    rdebliek
  • johannafalk
    johannafalk

jdh
Contributor
  • Contributor

There is currently no simple way to have truly dynamic attribute mapping.

I would like the ability to provide an input file, a mapping file (old attribute, new attribute) and get an output that is identical to the input except for the attribute names.


While the schemaMapper allows you to dynamically rename attributes referencing an external lookup table, that lookup table is hardcoded, you cannot use a parameter to specify it.


Additionally you cannot dynamically write out the changed attributes. All the schemaMapper examples assume hard coded attributes on the writer, which can lead to issues if the mapping table is updated and the writer is not. Both automatic and dynamic mode use the original schema unless schema from schema feature is selected.


While one can use the SchemaSetter custom transformer to generate the new schema feature, it has the flaw that all strings are mapped to varchar(256) , leading to significant bloat in the output file when the original attribute might only be a few characters.


Two updates to the schema mapper would allow this dynamic ability without having to script it in python.

  1. Allow the Schema mapping table to be set by a user parameter, or even an attribute.
  2. Have an output port on the SchemaMapper with an updated schema feature

1 reply

jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • November 2, 2021

My current workaround is to use a FeatureReader and send both the schema feature and data features to a pythonCaller where in the __init__ the mapping csv is read in turned into a dictionary (key: old name, value: new name) and in the input both the schema feature attribute{i}.name and the data feature attributes are renamed by looping through the attributes and using the mappingDictionary.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings