Question

Best practice for checking attribute values

  • 29 April 2016
  • 7 replies
  • 70 views

Badge +2

I'm working with a workbench which is supposed to check if several attribute values ( five attributes) exceeds a limit (each attribute has its own limit). I'm using an sqlexecutor to get the feature and one for getting the limits. If one of the values exceeds the limit I want to write the name of the attribute and value to a string variable. I've tried using a testfilter (5 testqueries) connected to an attributecreator and stringconcatenator, but this doesn't seem to work since I only have one feature on the testfilter input.

Does anyone have a good solution for this?


7 replies

Userlevel 4

Hi

Have you considered the AttributeValidator that was introduced in FME 2016?

David

Badge

Attribute Manager conditional statements are good as well. Basically if you have a database that is centered around the use of drop down lists or there is a finite amount of acceptable values in a column then you can use if statements to check that all values are acceptable, if not then do nothing/change to null/flag it or set a default value for it. AttributeValidator is fantastic for checking exactly why a validation was failed, I believe the transformer creates a column _fme_validation_message. And it states why a record failed and exactly WHERE it failed, which is invaluable for troubleshooting validation problems. Hope this helps :)

Userlevel 2
Badge +16

The TestFilter is using an If .. Elsif..Else construction.

So if the first test passes the other tests will not be executed.

If your feature fails all conditions only one output will be shown.

If you need all tests to be performed I would go with 5 Testers and connect the Passed port (Value > limit) to an AttributeCreator and route both streams to the next Tester.

This way all tests are performed and possibly 5 result attributes are created.

Badge +3

i would go for a attributecreator ( manager in 2016 i believe).

Either use conditional creation (as stated by Rycharge) or use expression or regexp. to do that.

Userlevel 2
Badge +17

Hi @torbjornd, if you are looking for a way to merge the limit values to the features from the SQLExecutor, the FeatureMerger might help you. You can set an identical constant (e.g. 1) to the "Join One" parameter for both Requestor and Supplier, to merge Supplier's attributes to Requestors unconditionally.

Userlevel 4
Badge +25

I would go with the AttributeManager using conditional functionality. You don't want a "filter" transformer because you want to just test/set values, not filter the data. You really need a "mapper" transformer. The AttributeRangeMapper would probably work here, but in general we need to implement a mapper transformer that is similar to the conditional tools, but easier to find/understand.

Badge +2

Attribute Manager conditional statements are good as well. Basically if you have a database that is centered around the use of drop down lists or there is a finite amount of acceptable values in a column then you can use if statements to check that all values are acceptable, if not then do nothing/change to null/flag it or set a default value for it. AttributeValidator is fantastic for checking exactly why a validation was failed, I believe the transformer creates a column _fme_validation_message. And it states why a record failed and exactly WHERE it failed, which is invaluable for troubleshooting validation problems. Hope this helps :)

Thank you. I've tried using the AttributeValidator, but that transformer throws an error when I'm using a attribute value as "upper limit value". If I manually set the limit, it works. This is the error-message:

Illegal operator `RANGE' supplied for test evaluation -- operator must be one of < > <= >= != = ==

Reply