tustvold commented on code in PR #2040:
URL: https://github.com/apache/arrow-rs/pull/2040#discussion_r921478821
##########
arrow/src/ipc/writer.rs:
##########
@@ -1501,10 +1690,151 @@ mod tests {
#[test]
fn test_write_union_file_v4_v5() {
write_union_file(
- IpcWriteOptions::try_new(8, false, MetadataVersion::V4).unwrap(),
+ IpcWriteOptions::try_new(8, false, MetadataVersion::V4,
false).unwrap(),
);
write_union_file(
- IpcWriteOptions::try_new(8, false, MetadataVersion::V5).unwrap(),
+ IpcWriteOptions::try_new(8, false, MetadataVersion::V5,
false).unwrap(),
+ );
+ }
+
+ fn serialize_with_truncate(record: &RecordBatch) -> Vec<u8> {
+ let write_options = IpcWriteOptions::default();
+ serialize(record, write_options)
+ }
+
+ fn serialize_without_truncate(record: &RecordBatch) -> Vec<u8> {
+ let write_options =
+ IpcWriteOptions::try_new(8, false, MetadataVersion::V5,
false).unwrap();
+ serialize(record, write_options)
+ }
+
+ fn serialize(record: &RecordBatch, write_options: IpcWriteOptions) ->
Vec<u8> {
+ let buffer: Vec<u8> = Vec::new();
+ let mut stream_writer =
+ StreamWriter::try_new_with_options(buffer, &record.schema(),
write_options)
+ .unwrap();
+ stream_writer.write(record).unwrap();
+ stream_writer.finish().unwrap();
+ stream_writer.into_inner().unwrap()
+ }
+
+ fn deserialize(bytes: Vec<u8>) -> RecordBatch {
+ let mut stream_reader =
+ ipc::reader::StreamReader::try_new(std::io::Cursor::new(bytes),
None)
+ .unwrap();
+ stream_reader.next().unwrap().unwrap()
+ }
+
+ #[test]
+ fn truncate_ipc_record_batch() {
+ fn create_batch(rows: usize) -> RecordBatch {
+ let schema = Schema::new(vec![
+ Field::new("a", DataType::Int32, false),
+ Field::new("b", DataType::Utf8, false),
+ ]);
+
+ let a = Int32Array::from(vec![1; rows]);
+ let b = StringArray::from(vec!["a"; rows]);
Review Comment:
This PR fails with the above change, which would suggest something isn't
quite right
--
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]