Assuming Java: Are you using a ResolvingDecoder?
This will happen by default if you are reading Generic or Specific records from
an Avro File, but if you are reading data otherwise, you have to use a
ResolvingDecoder to specify the expected (reader) and actual (writer) schemas.
On Sep 16, 2010, at 1:09 AM, Robin Müller wrote:
> Hi,
>
> I've read the part "Schema Resolution" of the Avro Specification. So I
> think that avro supports versioning of the schema.
> But when I try to change to following schema, an AvroTypeException will
> be thrown by reading data that was serialized with the old schema:
> {
> "name":"BrowserCountArray",
> "type":"record",
> "fields": [
> {
> "name":"BrowserCounts",
> "type":
> {
> "type":"array",
> "items": {
> "name": "BrowserCount",
> "type": "record",
> "fields": [
> {
> "name":"Browser",
> "type":"string"
> }, {
> "name":"Count",
> "type":"int"
> }]
> }
> }
> }]
> }
>
> For example I add a new field to the BrowserCount record like this:
>
> {
> "name":"BrowserCountArray",
> "type":"record",
> "fields": [
> {
> "name":"BrowserCounts",
> "type":
> {
> "type":"array",
> "items": {
> "name": "BrowserCount",
> "type": "record",
> "fields": [
> {
> "name":"Browser",
> "type":"string"
> }, {
> "name":"Count",
> "type":"int"
> }, {
> "name":"Blub",
> "type":"int",
> "default":"0"
> }]
> }
> }
> }]
> }
>
> Is it possible to add or remove fields from this record and read with
> this new schema data, that was serialized with an old one.
> Or is there another way to define an array of record which solves that
> problem.
>
> Thanks,
> Robin