Stephen0421 commented on code in PR #9148:
URL: https://github.com/apache/paimon/pull/9148#discussion_r3773754005
##########
paimon-python/pypaimon/write/blob_format_writer.py:
##########
@@ -290,17 +290,38 @@ def _write_blob_data(self, blob_value: Blob, crc32: int):
data = blob_value.to_data()
crc32 = self._write_with_crc(data, crc32)
else:
+ expected_length = None
+ if type(blob_value) is BlobRef:
+ descriptor_length = blob_value.to_descriptor().length
+ if descriptor_length >= 0:
+ expected_length = descriptor_length
stream = blob_value.new_input_stream()
try:
- chunk = stream.read(self.copy_buffer_size)
- while chunk:
- crc32 = self._write_with_crc(chunk, crc32)
+ if expected_length is not None:
+ crc32 = self._copy_exactly(stream, expected_length, crc32)
+ else:
chunk = stream.read(self.copy_buffer_size)
+ while chunk:
+ crc32 = self._write_with_crc(chunk, crc32)
+ chunk = stream.read(self.copy_buffer_size)
finally:
stream.close()
Review Comment:
Fixed. `_write_blob_data` now keeps the copy/read exception (including
`EOFError`) and only surfaces a `close()` failure if the copy succeeded. Added
tests for close-failing truncated copy and close-failing successful copy.
--
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]