This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-12094-71a9574e657710383e22cfa528ecaa415a3f9a05 in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit 56b18950f5c8b1790b5d0076c4fe4ffc8ac42c80 Author: Oleks V <[email protected]> AuthorDate: Thu Nov 5 22:20:39 2026 +0000 fix(arrow-ipc): honor skip_validation for record batches in StreamDecoder (#12094) # Which issue does this PR close? - Relates to apache/datafusion#26687. This picks up #11552 by @Dandandan with the same fix, rebased on `main`. The benchmarks are split out into #12093. # Rationale for this change `StreamDecoder::with_skip_validation(true)` only applies to dictionary batches, so record batches are still fully validated. `StreamReader`, `FileDecoder` and the `arrow-flight` `FlightDataDecoder` all pass the flag through for record batches too. DataFusion's spill reader has called `StreamDecoder::new().with_skip_validation(true)` since apache/datafusion#21882. Because of this bug, every spilled batch is validated again when it is read back, including a UTF-8 check of every string. That undoes apache/datafusion#15454. # What changes are included in this PR? - Pass `skip_validation` to `RecordBatchDecoder` in `StreamDecoder::decode`. - Cover `StreamDecoder` in `expect_ipc_validation_error`. # Are these changes tested? Yes. `expect_ipc_validation_error` now checks that `StreamDecoder` rejects invalid data by default and accepts it when validation is skipped. Without the fix, the five `test_validation_of_invalid_*` tests fail on the new check. Benchmarks from #12093 on an M5 Max, `main` against this PR: | Benchmark | main | this PR | Change | |---|---|---|---| | `StreamDecoder/no_validation/read_10` | 129.0 µs | 6.18 µs | −95.2% | | `StreamDecoder/read_10` | 128.9 µs | 128.8 µs | no change | The `StreamReader` and `FileReader` benchmarks do not change. With arrow patched to this branch, DataFusion's `spill_io/StreamReader/read_100` drops from 9.59 ms to 8.48 ms (−11.5%). That benchmark reads 100 spilled batches of 8192 rows through `StreamDecoder`. After #12093 merges, rebasing this PR lets `run benchmark ipc_reader` confirm these numbers on the shared runner. # Are there any significant user-facing changes? No API changes, and validation is still on by default. Callers that pass `true` now skip validation for record batches too, as documented. AI disclosure: The fix, the test and this description were written with Claude Code. I have reviewed every change and the benchmark results. Co-authored-by: RIchard Baah <[email protected]> --- arrow-ipc/src/reader.rs | 15 +++++++++++++++ arrow-ipc/src/reader/stream.rs | 1 + 2 files changed, 16 insertions(+) diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs index e19af5f0bd..ea3026319e 100644 --- a/arrow-ipc/src/reader.rs +++ b/arrow-ipc/src/reader.rs @@ -2956,6 +2956,16 @@ mod tests { reader.next().unwrap() } + /// Return the first record batch read from the IPC Stream buffer + /// using the StreamDecoder API + fn read_stream_with_decoder( + buf: &[u8], + skip_validation: bool, + ) -> Result<RecordBatch, ArrowError> { + let mut decoder = unsafe { StreamDecoder::new().with_skip_validation(skip_validation) }; + Ok(decoder.decode(&mut Buffer::from(buf))?.unwrap()) + } + fn roundtrip_ipc_stream(rb: &RecordBatch) -> RecordBatch { let buf = write_stream(rb); read_stream(&buf).unwrap() @@ -4035,6 +4045,11 @@ mod tests { let err = read_stream(&buf).unwrap_err(); assert_eq!(err.to_string(), expected_err); + // IPC Stream format with StreamDecoder + read_stream_with_decoder(&buf, true).unwrap(); + let err = read_stream_with_decoder(&buf, false).unwrap_err(); + assert_eq!(err.to_string(), expected_err); + // IPC File format let buf = write_ipc(&rb); // write is ok read_ipc_skip_validation(&buf).unwrap(); diff --git a/arrow-ipc/src/reader/stream.rs b/arrow-ipc/src/reader/stream.rs index b8c9d31314..95ccd1a1dc 100644 --- a/arrow-ipc/src/reader/stream.rs +++ b/arrow-ipc/src/reader/stream.rs @@ -249,6 +249,7 @@ impl StreamDecoder { &version, )? .with_require_alignment(self.require_alignment) + .with_skip_validation(self.skip_validation.clone()) .read_record_batch()?; self.state = DecoderState::default(); return Ok(Some(batch));
