diff --git a/parquet/src/file/writer.rs b/parquet/src/file/writer.rs index eaeee9ad4fc..f8830ff0778 100644 --- a/parquet/src/file/writer.rs +++ b/parquet/src/file/writer.rs @@ -729,7 +729,10 @@ impl PageWriter for SerializedPageWriter { mod tests { use super::*; + #[cfg(not(target_os = "windows"))] use std::os::unix::fs::FileExt; + #[cfg(target_os = "windows")] + use std::os::windows::fs::FileExt; use std::{ fs::File, io::{Cursor, SeekFrom}, @@ -1264,6 +1267,7 @@ mod tests { assert_eq!(to_thrift(left.statistics()), to_thrift(right.statistics())); } + #[cfg(not(target_os = "windows"))] fn assert_magic(file: &mut File, expected: [u8; 4]) { let length = file.len(); // Of course the file has to be larger than just 8, but we're just sanity-checking when checking the magic. @@ -1276,6 +1280,23 @@ mod tests { assert_eq!(buf, expected); } + #[cfg(target_os = "windows")] + fn assert_magic(file: &mut File, expected: [u8; 4]) { + let length = file.len(); + // Of course the file has to be larger than just 8, but we're just sanity-checking when checking the magic. + assert!(length >= 8); + + let original_position = file.stream_position(); + + let mut buf = [0xCDu8, 0xCD, 0xCD, 0xCD]; + file.seek_read(&mut buf[..], 0).unwrap(); + assert_eq!(buf, expected); + file.seek_read(&mut buf[..], length - 4).unwrap(); + assert_eq!(buf, expected); + + file.seek(SeekFrom::Start(original_position)).unwrap(); + } + /// File write-read roundtrip. /// `data` consists of arrays of values for each row group. fn test_file_roundtrip(mut file: File, data: Vec>) {