You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Samuel Piercy <sa...@bethesda.net> on 2016/04/07 22:49:04 UTC

ConvertJSONToAvro floating point / double errors

In Nifi 0.6.0 with Java 1.7, the conversion of JSON data to Avro appears to reject the floating point values (both float and double).

Using the ConvertJSONToAvro processor and the following examples causes errors.

Sample Avro Schema:  
{"name": " sample_float_avro", "type": "record", "fields": [   {"name":"sampleLong", "type":["null", "long"]}  ,{"name":"sampleInt", "type":["null", "int"]}  ,{"name":"sampleFloat", "type":["null", "float"]} ]}

Fail Example:
{"sampleLong":123456, "sampleInt":345, "sampleFloat":10.1}

Success Example:
{"sampleLong":123456, "sampleInt":345, "sampleFloat":10}

Is anyone else experiencing similar issues?

Sam

Re: ConvertJSONToAvro floating point / double errors

Posted by Conrad Crampton <co...@SecData.com>.
I think I had the same or similar problem (with earlier version) and couldn’t get a direct Json->Avro to work with any Json numerical type. I ended up working around by having the Avro schema data types being String only and then doing a ConvertAvroSchema to move from the string only schema to the final intended one that included number types.
Can’t answer if the error though is intended behaviour for some reason unbeknown to me.
Regards
Conrad



On 07/04/2016, 21:49, "Samuel Piercy" <sa...@bethesda.net> wrote:

>In Nifi 0.6.0 with Java 1.7, the conversion of JSON data to Avro appears to reject the floating point values (both float and double).
>
>Using the ConvertJSONToAvro processor and the following examples causes errors.
>
>Sample Avro Schema:  
>{"name": " sample_float_avro", "type": "record", "fields": [   {"name":"sampleLong", "type":["null", "long"]}  ,{"name":"sampleInt", "type":["null", "int"]}  ,{"name":"sampleFloat", "type":["null", "float"]} ]}
>
>Fail Example:
>{"sampleLong":123456, "sampleInt":345, "sampleFloat":10.1}
>
>Success Example:
>{"sampleLong":123456, "sampleInt":345, "sampleFloat":10}
>
>Is anyone else experiencing similar issues?
>
>Sam
>
>
> ***This email originated outside SecureData***
>
>Click https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==  to report this email as spam.


SecureData, combating cyber threats
______________________________________________________________________ 
The information contained in this message or any of its attachments may be privileged and confidential and intended for the exclusive use of the intended recipient. If you are not the intended recipient any disclosure, reproduction, distribution or other dissemination or use of this communications is strictly prohibited. The views expressed in this email are those of the individual and not necessarily of SecureData Europe Ltd. Any prices quoted are only valid if followed up by a formal written quote.

SecureData Europe Limited. Registered in England & Wales 04365896. Registered Address: SecureData House, Hermitage Court, Hermitage Lane, Maidstone, Kent, ME16 9NT