Conditionally transform date on sentinel value?

I’m reading an input file, where one field is either a date in the format yyyymmdd (e.g, “20001231”) or a sentinel value, “99999999”. (Yeah, great decision!)

I can’t make the metadata , as that doesn’t parse the sentinel value.

I assume I need to make the metadata for that field a string, connect to the Reader’s output a ReformatTransform?

In the transform, how can I
a) pass all other fields unchanged, and
b) do the equivalent of the java code

Date transformedField = ( field == null || "99999999".equals( field ) ? null : dateFormatter.parse( field ) ) ;

Thanks.

Hello,
the easiest way is to use nullValue attribute on the metadata.
Or, as you wrote, in Reformat:

  • you can use your code in transformation written in java

  • use following code with CTL2:

	$0.avalue = iif(isnull($avalue) || $avalue == "99999999" , null, str2date($0.avalue,"yyyyMMdd"));  

Btw: fix the format - mm is minute, MM is month.

Ah! The nullValue attribute is much easier. Thanks!