avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mani dunga <mani.du...@gmail.com>
Subject Re: Optional string in avro scheme
Date Tue, 19 May 2015 18:10:14 GMT
Error: Found interface org.apache.hadoop.mapreduce.TaskAttemptContext, but
class was expected


how can we solve this.




On Tue, May 19, 2015 at 6:34 AM, Emre Sevinc <emre.sevinc@gmail.com> wrote:

> Hello Dmitry,
>
> Does the following SO answer help you:
>
>  http://stackoverflow.com/a/27499930/236007
>
>
> Kind regards,
> Emre Sevinç
>
>
> On Fri, May 15, 2015 at 9:44 AM, Dzmitry Hancharou <goncharovda@gmail.com>
> wrote:
>
>> Hello all,
>>
>> I want to convert json with optional string field into binary avro file.
>>
>> The following scheme is used:
>> Optional.avsc:
>>     {
>>         "namespace": "Namespace",
>>         "type": "record",
>>         "name": "Optional",
>>         "fields": [
>>             {
>>                 "name": "opt",
>>                 "type": ["null", "string"],
>>                 "default": null
>>             },
>>             {
>>                 "name": "req",
>>                 "type": "string"
>>             }
>>         ]
>>     }
>>
>> optional.json: {"req": "xxx"}
>>
>> When I run "java -jar avro-tools-1.7.7.jar fromjson --schema-file
>> Optional.avsc optional.json > optional.avro", get exception:
>> Exception in thread "main" org.apache.avro.AvroTypeException: Expected
>> field name not found: opt
>> at org.apache.avro.io.JsonDecoder.doAction(JsonDecoder.java:477)
>> at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
>> at org.apache.avro.io.JsonDecoder.advance(JsonDecoder.java:139)
>> at org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:429)
>> at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290)
>> at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
>> at
>> org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
>> at
>> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:155)
>> at
>> org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:193)
>> at
>> org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:183)
>> at
>> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:151)
>> at
>> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
>> at org.apache.avro.tool.DataFileWriteTool.run(DataFileWriteTool.java:99)
>> at org.apache.avro.tool.Main.run(Main.java:84)
>> at org.apache.avro.tool.Main.main(Main.java:73)
>>
>> When I change optional.json to {"opt": "yyy", "req": "xxx"}, I get
>> Exception in thread "main" org.apache.avro.AvroTypeException: Expected
>> start-union. Got VALUE_STRING
>> at org.apache.avro.io.JsonDecoder.error(JsonDecoder.java:697)
>> at org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:441)
>> at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290)
>> at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
>> at
>> org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
>> at
>> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:155)
>> at
>> org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:193)
>> at
>> org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:183)
>> at
>> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:151)
>> at
>> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
>> at org.apache.avro.tool.DataFileWriteTool.run(DataFileWriteTool.java:99)
>> at org.apache.avro.tool.Main.run(Main.java:84)
>> at org.apache.avro.tool.Main.main(Main.java:73)
>>
>> What I'm doing wrong?
>>
>> Thanks,
>> Dmitry
>>
>>
>>
>
>
> --
> Emre Sevinc
>



-- 
Regards,

*MANI*

Mime
View raw message