Skip to main content

Converting Int, Long and String to Boolean Values.

  • February 19, 2022
  • 0 replies
  • 372 views

AkshayJadhav
StreamSets Employee
Forum|alt.badge.img

When using a Field Type Converter, some values are evaluated to determine if the conversion to Boolean can be made automatically.  For example, for integer and long values, 0 converts to false, all other integers (negative integers included) convert to true.

 

Numbers in String format such as “0”, “1”, “27” are all converted to false.

If you have a String value containing the the words, “true” or “false” they are converted to the appropriate Boolean values regardless of capitalization.

 

If you have a String value which is not “true” or “false” and needs to be converted to a Boolean, we can use an Expression Evaluator, such as:

${str:toUpper(record:value('/val')) == 'GOOD' ||  str:toUpper(record:value('/val')) == ‘OK’ }

 

This evaluates to true, when the field contains “good” or "ok" (in any case).

Additional Information about Expression Language can be found in the documentation:

https://streamsets.com/documentation/datacollector/latest/help//index.html#Expression_Language/ExpressionLanguage_overview.html#concept_p54_4kl_vq

Did this topic help you find an answer to your question?

0 replies

Be the first to reply!

Reply