TheNeuralBit commented on code in PR #22561:
URL: https://github.com/apache/beam/pull/22561#discussion_r941811471


##########
sdks/python/apache_beam/coders/row_coder.py:
##########
@@ -163,10 +165,15 @@ def _nonnull_coder_from_type(field_type):
         _coder_from_type(field_type.map_type.key_type),
         _coder_from_type(field_type.map_type.value_type))
   elif type_info == "logical_type":
-    # Special case for the Any logical type. Just use the default coder for an
-    # unknown Python object.
     if field_type.logical_type.urn == PYTHON_ANY_URN:
+      # Special case for the Any logical type. Just use the default coder for 
an
+      # unknown Python object.
       return typecoders.registry.get_coder(object)
+    elif field_type.logical_type.urn == DATETIME_URN:
+      # Special case for datetime logical type.
+      # DATETIME_URN explicitly uses TimestampCoder which deals with fix length
+      # 8-bytes big-endian-long instead of varint coder.
+      return TimestampCoder()

Review Comment:
   If we do implement `beam:logical_type:datetime` in Python we should:
   - Add the logical type in schema.proto, and reference the URN from that 
file: 
https://github.com/apache/beam/blob/4799828f75309fd494e14eab5af40559e9a140a3/model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/schema.proto#L117
   - Consider if we can keep the logic contained in the logical type 
implementation, e.g. can we do the byte flipping in a to_language_type and 
to_representation_type implementation?
   - Add some test cases to standard_coders.yaml, like this one: 
https://github.com/apache/beam/blob/4799828f75309fd494e14eab5af40559e9a140a3/model/fn-execution/src/main/resources/org/apache/beam/model/fnexecution/v1/standard_coders.yaml#L449-L454
 You might also need to skip this case in Go if the "logical" filter doesn't 
catch it: 
https://github.com/apache/beam/blob/4799828f75309fd494e14eab5af40559e9a140a3/sdks/go/test/regression/coders/fromyaml/fromyaml.go#L51



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