Hi everyone,

We have an application that receives Avro data, and it needs to rename
certain fields in the data before sending it downstream. The
application is using the following Avro schema to send the data
downstream (note that 2 of the fields have aliases defined):

{
    "name":"MyCompanyRecordAvroEncoder",
    "aliases":["com.mycompany.avro.MyStats"],
    "type":"record",
    "fields":[
        {"name":"newFieldName1","type":["null",
"int"],"default":null,"aliases":["oldFieldName1"]}
        
{"name":"statusRecords","type":{"type":"array","items":{"name":"StatusAvroRecord","type":"record","fields"
: [
            {"name":"recordId","type":"long"},
            {"name":"recordName","type":["null", "string"],"default":null},
            {"name":"newFieldName2","type":["null",
"string"],"default":null,"aliases":["oldFieldName2"]}
        ]}}, "default": []}
    ]
}

We see that our application receives the following Avro data:

{
    "oldFieldName1": 300,
    "statusRecords": [
        {
            "recordId": 100,
            "recordName": "Record1",
            "oldFieldName2":
"{\"type\":\"XYZ\",\"properties\":{\"property1\":-1.2,\"property2\":\"Value\"}}"
        }
    ]
}

Then the application sends the following Avro data downstream:

{
     "newFieldName1": 300,
     "statusRecords": [
         {
             "recordId": 100,
             "recordName": "Record1",
             "newFieldName2": null
         }
     ]
}

As you can see, newFieldName1 is aliased to oldFieldName1 and has the
value from oldFieldName1, so its alias is working.

However, newFieldName2 is aliased to oldFieldName2, but it is null
instead of having the value from oldFieldName2, so its alias is not
working.

The only difference I see between newFieldName1 and newFieldName2 is
that newFieldName2 is a field within an array item. Do aliases not
work for fields in array items? Or is there some other issue?

Any idea how can I get the alias for newFieldName2 to work?

Thanks,
Spencer

Reply via email to