Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Transform string to integer in NiFi

avatar
Contributor

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": {}
  }
]

 

 

 

1 ACCEPTED SOLUTION

avatar
Expert Contributor

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

 

Change 

"=toInteger"

to

"=toLong"

 

View solution in original post

3 REPLIES 3

avatar
Expert Contributor

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

 

Change 

"=toInteger"

to

"=toLong"

 

avatar
Contributor

Thanks @Faerballert 

avatar
New Contributor

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