damccorm commented on code in PR #35459:
URL: https://github.com/apache/beam/pull/35459#discussion_r2177645318


##########
sdks/python/apache_beam/io/avroio.py:
##########
@@ -554,11 +554,11 @@ def avro_union_type_to_beam_type(union_type: List) -> 
schema_pb2.FieldType:
   """
   if len(union_type) == 2 and "null" in union_type:
     for avro_type in union_type:
-      if avro_type in AVRO_PRIMITIVES_TO_BEAM_PRIMITIVES:
-        return schema_pb2.FieldType(
-            atomic_type=AVRO_PRIMITIVES_TO_BEAM_PRIMITIVES[avro_type],
-            nullable=True)
-    return schemas.typing_to_runner_api(Any)
+      if avro_type != "null":
+        beam_type = avro_type_to_beam_type(avro_type)
+        if beam_type.WhichOneof("type_info") == "atomic_type":
+          return schema_pb2.FieldType(
+              atomic_type=beam_type.atomic_type, nullable=True)

Review Comment:
   I like this approach, it is simpler than what I was suggesting. With that 
said, are we able to just do something like this?
   
   ```suggestion
           beam_type.nullable = True
           return beam_type
   ```
   
   That way we're not just handling this for atomic types but for all types



-- 
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