Skip to main content
Solved

Test for feature count mismatch

  • February 15, 2017
  • 4 replies
  • 132 views

jeroen
Contributor
Forum|alt.badge.img+8

I'm building quite a lot of flows where the amount of input features should always be the same as the amount of output features. During the processing of the data a lot of transformers merge, delete, split, and aggregate the data but in the end it should always result in the same amount of features as i started.

I now use an UniqueValueLogger to list all the ID's in between and then compare it and at the end i do a manual check to see if the correct amount of features are written to the writer. But i was wondering if this could be tested with the tester and if it does not match can stop the translation raising an error that the input data is not correctly formatted.

Best answer by takashi

Agree that the FeatureWriter is a good way to get the number of written features.

Another thought. If you want to test the number of features to be written BEFORE writing them into the destination dataset, you can use two global variables which count the number of features passed through the link before/after the translation, like this. Note that a FeatureHolder is used here to save the final count numbers into the variables.

Python global variables can also be used, with two PythonCallers.

View original
Did this help you find an answer to your question?

Forum|alt.badge.img+7

Hi @jdh009

Did you already take a look at the FeatureWriter for writing your data? It provides some statistics (e.g. the amount of features written) that might be useful. For more information, click here:

https://docs.safe.com/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/featurewriter.htm


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • February 15, 2017

The FeatureWriter + SQLExecutor is a good option to verify.

I also use a technique in which I parse the workspace log and compare the features read and written.

Hope this helps.


takashi
Supporter
  • February 15, 2017

Agree that the FeatureWriter is a good way to get the number of written features.

Another thought. If you want to test the number of features to be written BEFORE writing them into the destination dataset, you can use two global variables which count the number of features passed through the link before/after the translation, like this. Note that a FeatureHolder is used here to save the final count numbers into the variables.

Python global variables can also be used, with two PythonCallers.


cheffing
Forum|alt.badge.img

What about this way:

Make an custom transformer from

  • an inlinequerier with a simple "select count(*) from table"
  • and a tester on the result: @Value(count(*))!=valuetotest

valuetotest might be a global variable

???


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