Avro Schema GenericRecord Nullable

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x ] Documentation issue or request

Current behavior

Expected behavior

Minimal reproduction of the problem

Environment

  • [ x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [x ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
Hi Sebastian
I am trying set a nullable GenericRecord in Avro Schema of Kafka. The problem is that when value is available, it adds the extra key.

Example

Avro Schema

			"name": "country",
			"type": ["null", {
				"name": "country",
                                "type": "record",
							"fields": [
							{
								"name": "id",
								"type": "string"
							},
							{
								"name": "type",
								"type": "string"
							}]
						}]}

Payload

"country": 
	{% if country.id != null %}
			{
				"id" : "{{country.id}}",
				"type" : "country"
			},
			{% else %} "",
	{% endif %}

**Result - for null country **

 "country": null

**Result - for none null country **

 "country": {
      "namespace.country": {
        "id": "1",
        "type": "Italy"}

How can I get rid of “namespace.country” ?
I want …

 "country": {
        "id": "1",
        "type": "Italy"}

Thanks in advance

Can you format your code properly? It is hard to understand.

Edit: Just did it, but I have no idea. Have you tried JSON first to understand if the JSON is correct? It converts from JSON to Avro.