You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/08/01 11:13:43 UTC
[GitHub] [arrow-rs] alamb commented on a diff in pull request #2254: Add tests for reading nested decimal arrays from parquet
alamb commented on code in PR #2254:
URL: https://github.com/apache/arrow-rs/pull/2254#discussion_r934412546
##########
parquet/src/arrow/arrow_reader.rs:
##########
@@ -729,6 +730,87 @@ mod tests {
}
}
+ #[test]
+ fn test_decimal_nullable_struct() {
+ let decimals = Decimal128Array::from_iter_values([1, 2, 3, 4, 5, 6, 7, 8]);
+
+ let data = ArrayDataBuilder::new(ArrowDataType::Struct(vec![Field::new(
+ "decimals",
+ decimals.data_type().clone(),
+ false,
+ )]))
+ .len(8)
+ .null_bit_buffer(Some(Buffer::from(&[0b11101111])))
+ .child_data(vec![decimals.into_data()])
+ .build()
+ .unwrap();
+
+ let written = RecordBatch::try_from_iter([(
+ "struct",
+ Arc::new(StructArray::from(data)) as ArrayRef,
+ )])
+ .unwrap();
+
+ let mut buffer = Vec::with_capacity(1024);
+ let mut writer =
+ ArrowWriter::try_new(&mut buffer, written.schema(), None).unwrap();
+ writer.write(&written).unwrap();
+ writer.close().unwrap();
+
+ let read = ParquetFileArrowReader::try_new(Bytes::from(buffer))
+ .unwrap()
+ .get_record_reader(3)
+ .unwrap()
+ .collect::<ArrowResult<Vec<_>>>()
+ .unwrap();
+
+ assert_eq!(&written.slice(0, 3), &read[0]);
+ assert_eq!(&written.slice(3, 3), &read[1]);
+ assert_eq!(&written.slice(6, 2), &read[2]);
+ }
+
+ #[test]
+ #[ignore] // https://github.com/apache/arrow-rs/issues/2253
Review Comment:
👍 Testing FTW
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org