Stephen0421 commented on code in PR #9539:
URL: https://github.com/apache/paimon/pull/9539#discussion_r3920348178


##########
paimon-python/pypaimon/write/writer/dedicated_format_writer.py:
##########
@@ -436,16 +437,26 @@ def _validate_inline_stored_fields_input(self, data: 
pa.RecordBatch):
                         "blob-descriptor-field requires blob field value to be 
a serialized "
                         "BlobDescriptor."
                     )
+                descriptor_bytes = bytes(value)
+                if descriptor_bytes:
+                    version = descriptor_bytes[0]
+                    if version < 1 or version > BlobDescriptor.CURRENT_VERSION:
+                        raise ValueError(
+                            f"blob-descriptor-field requires BlobDescriptor 
version "
+                            f"in [1, {BlobDescriptor.CURRENT_VERSION}], but 
found "
+                            f"{version}."
+                        )
                 try:
-                    descriptor_bytes = bytes(value)
-                    descriptor = BlobDescriptor.deserialize(descriptor_bytes)
-                    if descriptor.serialize() != descriptor_bytes:
-                        raise ValueError("Descriptor payload contains trailing 
bytes.")
+                    BlobDescriptor.deserialize(descriptor_bytes)
                 except Exception as e:
                     raise ValueError(
                         "blob-descriptor-field requires blob field value to be 
a serialized "
                         "BlobDescriptor."
                     ) from e
+                # serialize() always emits CURRENT_VERSION, so a round-trip
+                # would reject exact v1 bytes. Check exact wire length instead.
+                if BlobDescriptor.parse_if_serialized(descriptor_bytes) is 
None:

Review Comment:
   Thranks. `parse_if_serialized()` now dispatches through 
`BlobDescriptorSerde`: an exact `VideoFrameDescriptor` is parsed with its 
exact-length deserializer first, then the ordinary v1/v2 length check. Writer 
validation still calls `BlobDescriptor.parse_if_serialized()`, so 
`VideoFrameDescriptor("file:///v.mp4", 0, 10, 2).serialize()` is accepted and 
padded input is still rejected.



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