nehsyc commented on a change in pull request #13069:
URL: https://github.com/apache/beam/pull/13069#discussion_r505804803



##########
File path: sdks/python/apache_beam/coders/coders_test_common.py
##########
@@ -570,6 +571,37 @@ def test_map_coder(self):
         }, {}, {i: str(i)
                 for i in range(5000)})
 
+  def test_sharded_key_coder(self):
+    coder = coders.ShardedKeyCoder(coders.BytesCoder())
+    # Verify cloud object representation
+    self.assertEqual({
+        '@type': 'kind:sharded_key',
+        'component_encodings': [coders.BytesCoder().as_cloud_object()]
+    },
+                     coder.as_cloud_object())
+
+    # Test binary representation
+    self.assertEqual(b'\x00\x00', coder.encode(ShardedKey(b'')))
+    self.assertEqual(b'\x00\x03key', coder.encode(ShardedKey(b'key')))
+    self.assertEqual(b'\x00\x00', coder.encode(ShardedKey(b'', b'')))
+    self.assertEqual(b'\x03123\00', coder.encode(ShardedKey(b'', b'123')))
+    self.assertEqual(b'\x03123\03key', coder.encode(ShardedKey(b'key', 
b'123')))
+
+    test_values = [
+        ShardedKey(b''),

Review comment:
       Added a string type and a tuple type.




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

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


Reply via email to