Skip to content

Commit

Permalink
validate that arrow IPC files include a valid embedded IPC stream wit…
Browse files Browse the repository at this point in the history
…h EOS
  • Loading branch information
bkietz committed Aug 26, 2024
1 parent 2328b6e commit 531ca4c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cpp/src/arrow/integration/json_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ static Status ValidateFull(const RecordBatch& batch) {
return Status::OK();
}

static Status ValidateEmbeddedStream(io::RandomAccessFile* arrow_file) {
RETURN_NOT_OK(arrow_file->Seek(8));
ARROW_ASSIGN_OR_RAISE(auto arrow_reader,
ipc::RecordBatchStreamReader::Open(arrow_file));
for (auto maybe_batch : *arrow_reader) {
RETURN_NOT_OK(maybe_batch.status());
}
return arrow_file->Seek(0);
}

static Status ValidateArrowVsJson(const std::string& arrow_path,
const std::string& json_path) {
// Construct JSON reader
Expand All @@ -160,6 +170,7 @@ static Status ValidateArrowVsJson(const std::string& arrow_path,

// Construct Arrow reader
ARROW_ASSIGN_OR_RAISE(auto arrow_file, io::ReadableFile::Open(arrow_path));
RETURN_NOT_OK(ValidateEmbeddedStream(arrow_file.get()));

std::shared_ptr<ipc::RecordBatchFileReader> arrow_reader;
ARROW_ASSIGN_OR_RAISE(arrow_reader, ipc::RecordBatchFileReader::Open(arrow_file.get()));
Expand Down

0 comments on commit 531ca4c

Please sign in to comment.