From 8f0b9c4ac83016810aad9969ebd9c99941c1d5d5 Mon Sep 17 00:00:00 2001 From: Shrey Pant Date: Fri, 17 Apr 2026 02:11:46 +0530 Subject: [PATCH] feat(ipc): add with_skip_validation to StreamDecoder for parity with StreamReader --- arrow-ipc/src/reader/stream.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arrow-ipc/src/reader/stream.rs b/arrow-ipc/src/reader/stream.rs index d0d833b471b8..bfecf7b6ffa5 100644 --- a/arrow-ipc/src/reader/stream.rs +++ b/arrow-ipc/src/reader/stream.rs @@ -45,9 +45,8 @@ pub struct StreamDecoder { require_alignment: bool, /// Should validation be skipped when reading data? Defaults to false. /// - /// See [`FileDecoder::with_skip_validation`] for details. + /// See [`StreamDecoder::with_skip_validation`] for details. /// - /// [`FileDecoder::with_skip_validation`]: crate::reader::FileDecoder::with_skip_validation skip_validation: UnsafeFlag, } @@ -114,6 +113,20 @@ impl StreamDecoder { self.schema.as_ref().map(|schema| schema.clone()) } + /// Specifies if validation should be skipped when reading data (defaults to `false`) + /// + /// # Safety + /// + /// This flag must only be set to `true` when you trust the input data and are + /// sure the data you are reading is valid Arrow IPC stream data, otherwise + /// undefined behavior may result. + /// + /// For example, DataFusion uses this when reading spill files it wrote itself. + pub unsafe fn with_skip_validation(mut self, skip_validation: bool) -> Self { + unsafe { self.skip_validation.set(skip_validation) }; + self + } + /// Try to read the next [`RecordBatch`] from the provided [`Buffer`] /// /// [`Buffer::advance`] will be called on `buffer` for any consumed bytes.