You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Stefan Radu Popescu <st...@esolutions.ro> on 2020/07/30 17:30:20 UTC
AvroTypeException: Attempt to process a double when a string was expected
Hello,
I am having an issue with reading a GenericDatum from a json String written
with avro GenericDatumWriter.
Exception as in title.
*MCVE and details at*:
https://gist.github.com/PopescuStefanRadu/cea799614ba49b753238b77ac4b242e5
Avro versions tested:
1.9.2, 1.10.0
Java runtime:
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7-Ubuntu-1ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0.1+7-Ubuntu-1ubuntu1, mixed mode,
sharing)
Compiled towards: java 11.
I'd be very grateful if you could help me out.
Thank you,
Stefan Popescu
Re: AvroTypeException: Attempt to process a double when a string was expected
Posted by Ryan Skraba <ry...@skraba.com>.
Hello! Thanks for the MCVE -- I could reproduce your symptoms easily!
Even when you're using JSON encoding, you should use a
GenericDatumReader<> to read generic datum.
The Json.ObjectReader sounds correct but is actually for a different
JSON use case (storing any arbitrary JSON snippet in a known, valid
Avro schema). The error message is not very helpful, unfortunately,
but points to the differences between the first UNION in your record
and the Json.avsc that Json.ObjectReader implicitly assumes.
I hope this helps! Ryan
On Thu, Jul 30, 2020 at 7:30 PM Stefan Radu Popescu
<st...@esolutions.ro> wrote:
>
> Hello,
>
> I am having an issue with reading a GenericDatum from a json String written with avro GenericDatumWriter.
>
> Exception as in title.
> MCVE and details at:
> https://gist.github.com/PopescuStefanRadu/cea799614ba49b753238b77ac4b242e5
>
> Avro versions tested:
>
> 1.9.2, 1.10.0
>
> Java runtime:
>
> openjdk 14.0.1 2020-04-14
> OpenJDK Runtime Environment (build 14.0.1+7-Ubuntu-1ubuntu1)
> OpenJDK 64-Bit Server VM (build 14.0.1+7-Ubuntu-1ubuntu1, mixed mode, sharing)
>
> Compiled towards: java 11.
>
> I'd be very grateful if you could help me out.
>
> Thank you,
> Stefan Popescu