kojiromike commented on a change in pull request #1632:
URL: https://github.com/apache/avro/pull/1632#discussion_r841155379



##########
File path: lang/py/avro/__main__.py
##########
@@ -155,15 +154,20 @@ def convert(value: str, field: avro.schema.Field) -> 
Union[int, float, str, byte
         return value.lower() in ("1", "t", "true")
     if type_ == "null":
         return None
-    if type_ == "union":
-        return convert_union(value, field)
     raise avro.errors.UsageError("No valid conversion type")
 
 
+def convert(value: str, field: avro.schema.Field) -> Union[int, float, str, 
bytes, bool, None]:
+    type_ = field.type.type
+    return convert_union(value, field) if type_ == "union" else _cast(type_, 
value)
+
+
 def convert_union(value: str, field: avro.schema.Field) -> Union[int, float, 
str, bytes, bool, None]:
-    for name in (s.name for s in field.type.schemas):

Review comment:
       I don't understand how this could have worked as written.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to