def fix_record_for_avro(record, avro_schema):
for field in avro_schema.fields:
field_name = field.name
datatype = field.type.to_json()
if isinstance(datatype, dict):
// This is a record type definition so we need to recurse a level deeper.
record[field_name] = fix_record_for_avro(
record[field_name], avro.schema.Parse(json.dumps(datatype)))[0]
After Change
def fix_record_for_avro(record, avro_schema):
for field in avro_schema["fields"]:
field_name = field["name"]
datatype = field["type"]
if isinstance(datatype, dict):