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


##########
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:
   [P2] Keep exact VideoFrameDescriptor inputs valid
   
   `BlobDescriptor.deserialize()` dispatches through `BlobDescriptorSerde`, so 
an exact serialized `VideoFrameDescriptor` is a supported descriptor and the 
previous round-trip validation accepted it. The new `parse_if_serialized()` 
only implements the ordinary v1/v2 BlobDescriptor layouts; for 
`VideoFrameDescriptor("file:///v.mp4", 0, 10, 2).serialize()`, deserialization 
succeeds and reserialization is byte-for-byte equal, but this call returns 
`None`, so every such value is now rejected as having trailing bytes. Please 
dispatch the exact-length check through the serde (or special-case 
`VideoFrameDescriptor` with its exact-length deserializer) before applying the 
ordinary v1/v2 calculation.



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