You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by "Murali K. Kandula" <Mu...@threattrack.com> on 2014/11/12 16:53:59 UTC

Avro C : How update a record or add fields one at a time

Hello All,



"{\"type\":\"record\",\
  \"name\":\"Person\",\
  \"fields\":[\
     {\"name\": \"ID\", \"type\": \"long\"},\
     {\"name\": \"First\", \"type\": \"string\"},\
     {\"name\": \"Last\", \"type\": \"string\"},\
     {\"name\": \"Phone\", \"type\": \"string\"},\
     {\"name\": \"Age\", \"type\": \"int\"}]}”;


For the schema mentioned above is it possible to add fields one at a time for a particular record. Ex: Let say a record with values ( ID: 1, first: abcd, last:xyz, phone: 111-222-3344, age:30) can we write this record to the file with only the field ID(with value 1) and then later update the record with ID( of value 1) with first,last,phone and age.


Please let me know if it’s possible.


Thanks

Murali

Re: Avro C : How update a record or add fields one at a time

Posted by svante karlsson <sa...@csi.se>.
first I think your schema declares each field as mandatory. You should
use the union form to declare an optional field.

....

"type": ["null", "long"]

second - the avro file is not intended as a database - just serialize
the whole file again, updating does not really make sense.





2014-11-12 16:53 GMT+01:00 Murali K. Kandula <Murali.Kandula@threattrack.com
>:

>  Hello All,
>
>
>  "{\"type\":\"record\",\  \"name\":\"Person\",\  \"fields\":[\     {\"name\": \"ID\", \"type\": \"long\"},\     {\"name\": \"First\", \"type\": \"string\"},\     {\"name\": \"Last\", \"type\": \"string\"},\     {\"name\": \"Phone\", \"type\": \"string\"},\     {\"name\": \"Age\", \"type\": \"int\"}]}”;
>
>
> For the schema mentioned above is it possible to add fields one at a time for a particular record. Ex: Let say a record with values ( ID: 1, first: abcd, last:xyz, phone: 111-222-3344, age:30) can we write this record to the file with only the field ID(with value 1) and then later update the record with ID( of value 1) with first,last,phone and age.
>
>
> Please let me know if it’s possible.
>
>
> Thanks
>
> Murali
>
>