Support Questions

Find answers, ask questions, and share your expertise

Nifi Scientific conversion

avatar
New Contributor

I have a decimal field of precision 38 (ie decimal (38)). When reading using HiveQL, hiveQL is implicitly converting this as string. If i use QueryRecord to cast into Decimal(38), it's converted into scientific notation. Query record uses Avro reader and Avro writer. So it makes me believe the crux of the issue is "Avro reader" which is forcing conversion. Any ideas on avoiding this conversion.

 

Example:

This is the actual value 82592313688509164760188 and Nifi is converting this into 8.259231368850916E22

1 REPLY 1

avatar

I believe the root cause here is likely that NiFi has some limits in how accurately it can store numeric data types internally.

 

If you do not want to lose precesion, the best course of action is likely to indeed use a string under the hood.

 

I know an improvement is requested in this area to allow for greater numeric precision, but at this time I do not know the status of this.

 

---

Alternately, if I read your question the wrong way: The solution might also be to explicitly define the column type in Hive before writing, to avoid landing on string where it is not needed.


- Dennis Jaheruddin

If this answer helped, please mark it as 'solved' and/or if it is valuable for future readers please apply 'kudos'.