The following script derives schemas from varied file formats. Can I get this reviewed? What would the improvements look like:
def _null_allowed_in_cols(self):
for field in self.fields:
field["type"] = self._field_type_converter(field["type"])
if type(field["type"]) == list:
if "null" not in field["type"]:
field["type"].insert(0, "null")
else:
field["type"] = ["null", field["type"]]
def _field_type_converter(self, field_type) -> Union[str, list]:
if type(field_type) is dict or type(field_type) is avro.schema.ImmutableDict:
return field_type["type"]
elif type(field_type) is list:
return list(map(lambda x: self._field_type_converter(x), field_type))
else:
return field_type