Support Questions
Find answers, ask questions, and share your expertise

Transform string to integer in NiFi

Explorer

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

Accepted Solutions

Contributor

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

 

Change 

"=toInteger"

to

"=toLong"

 

View solution in original post

2 REPLIES 2

Contributor

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

 

Change 

"=toInteger"

to

"=toLong"

 

View solution in original post

Explorer

Thanks @Faerballert