Skip to main content
vatodorov19
Silver ⭐️⭐️⭐️
November 4, 2020
Solved

Transform string to integer in NiFi

How can I transform a string to an integer in NiFi? I tried JoltTransform, but the string is transformed to a negative (??) integer. In the example, below, the timestamp_start original string value 1677720088000 is transformed to -1612124736. What am I missing in my Jolt specification? Any help is appreciated. Is there an alternative to the JoltTransform - another processor?

 

Looks like this is a known issue: https://github.com/bazaarvoice/jolt/issues/749

 

Original JSON

vatodorov19_0-1604518179909.png

 

Transformed JSON

vatodorov19_1-1604518204614.png

 

 

Jolt Specification

 

[
{
"operation": "modify-overwrite-beta",
"spec": {
"timestamp_start": "=toInteger"
}
},
{
"operation": "default",
"spec": {}
}
]

 

 

 

Faerballert
Gold ⭐️
November 12, 2020

The problem is because your value is higher than the maximum of an integer

 

Change 

"=toInteger"

to

"=toLong"

 

3 replies

Faerballert
Gold ⭐️
November 12, 2020

The problem is because your value is higher than the maximum of an integer

 

Change 

"=toInteger"

to

"=toLong"

 

Translate
vatodorov19
Silver ⭐️⭐️⭐️
November 13, 2020

Thanks @Faerballert 

Translate
kowalma7
Silver ⭐️
February 18, 2022

what if the value is empty. How to set null value instead of empty string ?

Translate