Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Error parse number json into ConvertAvroToJson

Highlighted

Error parse number json into ConvertAvroToJson

Explorer

After executing a query with executesql, I get the following schema:

 


{"type":"record",
"name":"NiFi_ExecuteSQL_Record",
"namespace":"any.data",
"fields":[
{"name":"id","type":["null",{"type":"bytes","logicalType":"decimal","precision":10,"scale":0}]},
{"name":"attr1","type":["null",{"type":"bytes","logicalType":"decimal","precision":10,"scale":0}]},
{"name":"attr2","type":["null",{"type":"bytes","logicalType":"decimal","precision":10,"scale":0}]},
{"name":"attr3","type":["null","string"]}
]
}

 

 

when I convert avro to json using ConvertAvroToJson, the json that comes out is:

 


[ {
"id" : {
"bytes" : "\u0015"
},
"attr1" : {
"bytes" : "\u0001q"
},
"attr2" : {
"bytes" : "P"
},
"attr3" : "example_value"
} ]

 


instead I expected:

 


[ {
"id" : "1",
"attr1" "2",
"attr2" : "3",
"attr3" : "example_value"
} ]

 

 


How can I solve the problem?
Thank you

 

4 REPLIES 4

Re: Error parse number json into ConvertAvroToJson

Master Guru

@LuxIsterica 

 

Have you tried using the newer convertRecord processor to convert your input FlowFile content from Avro to json instead?  You config a Avro reader and json writer separately for this processor.

The ConvertAcroToJson processor is a much older processor that is deprecated in favor of the newer record based processors.

 

Thanks,

Matt

Re: Error parse number json into ConvertAvroToJson

Cloudera Employee

Hi,

 

Have you tried to set JsonTreeReader in Reader property and AvroRecordSetWriter in Writer property and then use ConvertRecord processor, instead of directly using `ConvertJsonToAvro` and `ConverAvroToJson`?

Re: Error parse number json into ConvertAvroToJson

Explorer

Yes, I actually tried it and it seems to go "better", but I haven't completely solved it yet.

I used the ConvertRecord and I set up an AvroReader

avroreader.PNG

 

and a JsonRecordSetWrite

jsonwriter.PNG

 

 

but the numbers are float, while I need integer

Re: Error parse number json into ConvertAvroToJson

Cloudera Employee

Hey, Thanks for responding and confirming.

 

I understand that the output is in float and not an integer. I will update here when I find anything more helpful. Much appreciated.

Don't have an account?
Coming from Hortonworks? Activate your account here