SteNicholas commented on code in PR #392:
URL: https://github.com/apache/paimon-cpp/pull/392#discussion_r4131841560
##########
src/paimon/format/blob/blob_format_writer_test.cpp:
##########
@@ -933,6 +1077,46 @@ TEST_F(BlobFormatWriterWriteNullTest,
TestWriteNullOnExistsCheckFailure) {
}
}
+TEST_F(BlobFormatWriterWriteNullTest, TestCopyWithShortReads) {
+ const std::string data = "0123456789";
+ ASSERT_OK_AND_ASSIGN(std::shared_ptr<Blob> blob,
+ Blob::FromPath(WriteSourceFile("source.bin", data)));
+ ASSERT_OK_AND_ASSIGN(auto array, PrepareDescriptorArray(blob));
+
+ auto short_read_fs =
std::make_shared<ShortReadFileSystem>(/*max_read_size=*/3);
+ ASSERT_OK_AND_ASSIGN(
+ std::shared_ptr<BlobFormatWriter> writer,
+ BlobFormatWriter::Create(output_stream_, struct_type_,
+ /*write_null_on_missing_file=*/false,
+ /*write_null_on_fetch_failure=*/false,
+ /*write_placeholder=*/false, short_read_fs,
pool_));
+ ASSERT_OK(AddBatchOnce(writer, array));
+ ASSERT_OK(writer->Finish());
+ ASSERT_EQ(short_read_fs->ReadCallCount(), 4);
+
+ ASSERT_OK_AND_ASSIGN(std::shared_ptr<arrow::StructArray> result_struct,
ReadBackAsData());
+ ASSERT_EQ(result_struct->length(), 1);
+ auto binary_array =
checked_pointer_cast<arrow::LargeBinaryArray>(result_struct->field(0));
+ ASSERT_EQ(binary_array->GetString(0), data);
+
+ const std::vector<std::pair<Status, std::string>> cases = {
+ {Status::IOError("mock read error"), "mock read error"},
+ {Status::OK(), "unexpected end of blob data after 7 of 10 bytes: read
returned 0"}};
+ for (const auto& [end_status, expected_error] : cases) {
+ SCOPED_TRACE(expected_error);
+ ASSERT_OK_AND_ASSIGN(std::shared_ptr<BlobFormatWriter> failing_writer,
+ BlobFormatWriter::Create(
+ output_stream_, struct_type_,
/*write_null_on_missing_file=*/true,
+ /*write_null_on_fetch_failure=*/true,
/*write_placeholder=*/false,
+ std::make_shared<ShortReadFileSystem>(
+ /*max_read_size=*/3,
/*readable_length=*/7, end_status),
+ pool_));
+ Status status = AddBatchOnce(failing_writer, array);
+ ASSERT_NOK_WITH_MSG(status, "failed to copy BLOB field blob_col in row
0 of blob file");
+ ASSERT_NOK_WITH_MSG(status, expected_error);
+ }
Review Comment:
Makes sense. The short-read handling is reverted, and
`TestCopyWithShortReads` and `TestArrayBlobCopyWithShortReads` are removed with
it.
--
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]