Search code examples
apache-kafkaavrokafka-python

Could not make an Avro Schema object from date


I have an Avro schema with this property:

{"name": "whenDate", "type": ["date", "null"]}

I am using a Python client and the producer

confluent_kafka.avro.AvroProducer

When I load the Avro schema with aforementioned property, I trigger this error:

not a valid Avro schema: Type property "[u'date', u'null']" not a valid 
Avro schema: Union item must be a valid Avro schema: Could not make an Avro Schema object from date.

I presume this error speaks to limitations in the Confluent parser for Avro schema. That is, date is a logical type specified here, but it not as yet supported by the Confluent parser.

Can anyone confirm? More generally, should I assume that the Confluent parser does not handle the logical types for Avro schema? Thanks.


Solution

  • It is a logical type, I think you just need to declare it as a one.

    {"name": "date", "type": "int", "logicalType": "date"}