Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

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 Member

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