How to add a new field with a different record type using Avro in the schema registry?

Mariia Kharkhuta 0 Reputation points
2024-06-14T07:00:32.0033333+00:00

Hi all,

Can another record be used as the type field in the Avro schema?

Example:
Existed schema:

{
    "type": "record",
    "name": "Foo",
    "namespace": "com.example",
    "fields": [
        {
            "name": "foo_string",
            "type": "string"
        }
    ]
}

Trying to create:

{
    "type": "record",
    "name": "Bar",
    "namespace": "com.example",
    "fields": [
        {
            "name": "foo",
            "type": "com.example.Foo"
        }
    ]
}

Currently, there is an error:
Failed to add schema 'com.example.Bar' with error: {"error":{"code":"InvalidRequest","message":"Avro schema validation failed: Undefined name: com.example.Foo at 'fields[0].type'. TrackingId:ebe0a8ba-d77d-4888-b50a-76d7ca2be3bc_G0, ...}}

Thanks in advance!

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
585 questions
{count} votes