In a transformer, fitted with a reject link, I am mapping a string to a decimal type.
What I want to happen:-
If the incoming data is not a numeric string, e.g. 'aaaa' I want the row to be shunted into the reject link.
What actually happens (to my surprise)
The value is defaulted to zero, a warning is issued to the log, however the row continues on its merry way.
Is there any way of making the transformer behave the way I want? Or do I have to code up a validation for each and every decimal?
String to Decimal Validation
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 72
- Joined: Thu Sep 04, 2003 5:01 am
- Location: UK & Europe
String to Decimal Validation
Phil Clarke
Unfortunately, I would say that you would need to code up a "IsValid()" for each of those conversions.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Premium Member
- Posts: 72
- Joined: Thu Sep 04, 2003 5:01 am
- Location: UK & Europe
If all of the decimals have the same behaviour plus your source is a sequential stage, you could do the conversion from string to decimal implicitly when reading the data and then specify handling for decimals in the stage attributes.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Just for my understanding does that mean that the output row has to fail before its written to an reject link? eg trying to convert something for which there is no conversion.
And since the value here would be defaulting during its conversion that is not a failure hence no reject?
And since the value here would be defaulting during its conversion that is not a failure hence no reject?
Last edited by ShaneMuir on Wed Aug 08, 2012 1:43 am, edited 1 time in total.
String function Num() confirms that the string can be converted to a number. It is available in the Transformer constraints. The Otherwise/log function looks promising, Parallel Job Developer's Guide (7.x) page 16-17.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Hi Franklin
I think that is what Phil was trying to avoid - ie having a validation check for the field (whether it be IsValid() or Num()).
By having the conversion from string to decimal, and a reject link, it was hoped that when the conversion encountered a non numeric value that this would 'fail' and be sent down the reject link, removing the need to code a validation check. My understanding is that what actually happened is that the conversion from string to decimal has merely replaced a non numeric value with a default value of 0 and continued on its merry way.
I think that is what Phil was trying to avoid - ie having a validation check for the field (whether it be IsValid() or Num()).
By having the conversion from string to decimal, and a reject link, it was hoped that when the conversion encountered a non numeric value that this would 'fail' and be sent down the reject link, removing the need to code a validation check. My understanding is that what actually happened is that the conversion from string to decimal has merely replaced a non numeric value with a default value of 0 and continued on its merry way.