jrmccluskey commented on code in PR #41736:
URL: https://github.com/apache/beam/pull/41736#discussion_r4744785217


##########
sdks/python/apache_beam/io/avroio_test.py:
##########
@@ -28,6 +28,10 @@
 import tempfile
 import unittest
 from typing import Any
+from typing import Mapping

Review Comment:
   Use the collections.abc versions of Mapping and Sequence



##########
sdks/python/apache_beam/io/avroio.py:
##########
@@ -689,7 +690,8 @@ def beam_schema_to_avro_schema(
       schema_pb2.FieldType(row_type=schema_pb2.RowType(schema=beam_schema)))
 
 
-def unnest_primitive_type(beam_type: schema_pb2.FieldType):
+def unnest_primitive_type(
+    beam_type: schema_pb2.FieldType, defined_names: Optional[set] = None):

Review Comment:
   Add a type hint here to make the return type explicit



##########
sdks/python/apache_beam/io/avroio.py:
##########
@@ -762,6 +783,14 @@ def beam_row_to_avro_dict(
 
 def beam_value_to_avro_value(
     beam_type: schema_pb2.FieldType) -> Callable[[Any], Any]:
+  convert = _beam_value_to_avro_value(beam_type)
+  if beam_type.nullable and beam_type.WhichOneof("type_info") != "atomic_type":
+    return lambda value: None if value is None else convert(value)
+  return convert
+
+
+def _beam_value_to_avro_value(
+    beam_type: schema_pb2.FieldType) -> Callable[[Any], Any]:

Review Comment:
   I don't love the private-public split here, but I see why it exists 
structurally.



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