Hi everyone...
I am getting this error and would like any kind advice to solve please. Running confluent enterprise 4.1.1 with the following:
::My schema (2col.avsc)::
{"namespace": "com.example.avro",
"type": "record",
"name": "sor1",
"fields": [
{"name": "SRCE_BOOK_BRNCH", "int": "int"},
{"name": "NUM_FCLTY", "type": ["string", "null"], "default": null}
]
}
::My CSV (2col.csv)::
3110,
3110,
3110,1.30E+12
...
::My Code::
from confluent_kafka import avro
from confluent_kafka.avro import AvroProducer
import csv
AvroProducerConf = {'bootstrap.servers': '10.97.176.201:9092,10.97.176.202:9092,10.97.176.203:9092','schema.registry.url': 'http://localhost:8081'}
value_schema = avro.load('2col.avsc')
avroProducer = AvroProducer(AvroProducerConf, default_value_schema = value_schema)
with open('2col.csv', newline = '', encoding = 'utf-8') as f:
reader = csv.reader(f, delimiter = ',')
for row in reader:
avroProducer.produce(topic = '2col', value = {"SRCE_BOOK_BRNCH": row[0],"NUM_FCLTY": row[1]})
print(row)
avroProducer.flush()
::My Error::
...
File "/apps/home/kafka/.local/lib/python3.6/site-packages/avro/io.py", line 809, in write
raise AvroTypeException(self.writer_schema, datum)
avro.io.AvroTypeException: The datum {'SRCE_BOOK_BRNCH': '3110', 'NUM_FCLTY': ''} is not an example of the schema {...
Any ideas please?
Thank you in advance!
ravi
{"name": "SRCE_BOOK_BRNCH", "int": "int"},
Shouldn't that be
{"name": "SRCE_BOOK_BRNCH", "type": "int"},
Schema registry has nice rest api too
https://sachabarbs.wordpress.com
4 part series this may help you
Sorry but have to go on hols now
Good luck