alamb commented on code in PR #10545:
URL: https://github.com/apache/arrow-rs/pull/10545#discussion_r3731684657
##########
parquet/src/arrow/arrow_writer/mod.rs:
##########
@@ -3175,101 +3179,138 @@ mod tests {
})
}
- struct RoundTripOptions {
+ /// Round trip testing fixture:
+ ///
+ /// Tests based on this fixture write data to parquet and then read it
back.
+ struct RoundTripTest {
values: ArrayRef,
- schema: SchemaRef,
+ /// Optionally supplied schema
+ schema: Option<SchemaRef>,
+ /// If the created schema should be nullable. Defaults to true. Ignored
+ /// if schema is set to Some.
+ nullable: bool,
bloom_filter: bool,
bloom_filter_ndv: Option<u64>,
bloom_filter_position: BloomFilterPosition,
}
- impl RoundTripOptions {
- fn new(values: ArrayRef, nullable: bool) -> Self {
- let data_type = values.data_type().clone();
- let schema = Schema::new(vec![Field::new("col", data_type,
nullable)]);
+ impl RoundTripTest {
+ /// Create a test for round tripping values with a nullable schema
+ fn new(values: ArrayRef) -> Self {
Self {
values,
- schema: Arc::new(schema),
+ schema: None,
+ nullable: true,
bloom_filter: false,
bloom_filter_ndv: None,
bloom_filter_position: BloomFilterPosition::AfterRowGroup,
}
}
- }
- fn one_column_roundtrip(values: ArrayRef, nullable: bool) -> Vec<Bytes> {
- one_column_roundtrip_with_options(RoundTripOptions::new(values,
nullable))
- }
+ /// Set the schema
+ fn with_schema(mut self, schema: SchemaRef) -> Self {
+ self.schema = Some(schema);
+ self
+ }
- fn one_column_roundtrip_with_schema(values: ArrayRef, schema: SchemaRef)
-> Vec<Bytes> {
- let mut options = RoundTripOptions::new(values, false);
- options.schema = schema;
- one_column_roundtrip_with_options(options)
- }
+ /// Set the nullable flag
+ fn with_nullable(mut self, nullable: bool) -> Self {
+ self.nullable = nullable;
+ self
+ }
Review Comment:
Yeah, if you don't mind I am going to keep following the
Field::with_nullable API
I have big hopes to unify these round trip tests with the ones that use
record batches as well. We'll see if that is reasonable or not
--
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]