confluentinc / kafka-connect-datagen

Connector that generates data for demos
Apache License 2.0
19 stars 87 forks source link

Dependent schemas #133

Open Petkomat opened 1 year ago

Petkomat commented 1 year ago

I would like to use the schema (provided via schema.filename or schema.string or anyhow)

{
  "type": "record",
  "name": "Customer",
  "namespace": "com.example",
  "fields": [
    {
      "name": "country_born",
      "type": "com.example.Country"
    },
    {
      "name": "country_living",
      "type": "com.example.Country"
    }
  ]
}

which depends on the file country.avsc with the schema

 {
    "namespace": "com.example"
    "name": "Country",
    "type": "enum",
    "symbols": ["A", "B", "C"]
}

How can I do that?

Additional notes:

This kind of works with the following schema:

{
  "type": "record",
  "name": "Customer",
  "namespace": "com.example",
  "fields": [
    {
      "name": "country_born",
      "type": {
        "name": "Country1",
        "type": "enum",
        "symbols": ["A", "B", "C"]
      }
    },
    {
      "name": "country_living",
      "type": {
        "name": "Country2",
        "type": "enum",
        "symbols": ["A", "B", "C"]
      }
    }
  ]
}

but it is conceptually wrong to have two different enums Country1 and Country2. However, in the moment I make the names equal (e.g., Country, the error appears: "schema.string" : Unable to parse the provided schema