|
19 | 19 |
|
20 | 20 | use std::collections::hash_map::Entry; |
21 | 21 | use std::collections::HashMap; |
| 22 | +use std::ops::Deref; |
22 | 23 | use std::sync::atomic::AtomicI64; |
23 | 24 | use std::sync::Arc; |
24 | | -use std::ops::Deref; |
25 | 25 |
|
26 | | -use arrow_array::{Float32Array, Float64Array, ArrayRef, StructArray, ListArray, MapArray}; |
| 26 | +use arrow_array::{ArrayRef, Float32Array, Float64Array, ListArray, MapArray, StructArray}; |
27 | 27 | use arrow_schema::{DataType, SchemaRef as ArrowSchemaRef}; |
28 | 28 | use bytes::Bytes; |
29 | 29 | use futures::future::BoxFuture; |
@@ -791,12 +791,12 @@ mod tests { |
791 | 791 | use std::sync::Arc; |
792 | 792 |
|
793 | 793 | use anyhow::Result; |
794 | | - use arrow_array::types::{Int64Type, Float32Type}; |
| 794 | + use arrow_array::builder::{Float32Builder, Int32Builder, MapBuilder}; |
| 795 | + use arrow_array::types::{Float32Type, Int64Type}; |
795 | 796 | use arrow_array::{ |
796 | 797 | Array, ArrayRef, BooleanArray, Decimal128Array, Float32Array, Int32Array, Int64Array, |
797 | 798 | ListArray, RecordBatch, StructArray, |
798 | 799 | }; |
799 | | - use arrow_array::builder::{MapBuilder, Int32Builder, Float32Builder}; |
800 | 800 | use arrow_schema::{DataType, Field, Fields, SchemaRef as ArrowSchemaRef}; |
801 | 801 | use arrow_select::concat::concat_batches; |
802 | 802 | use parquet::arrow::PARQUET_FIELD_ID_META_KEY; |
@@ -1088,11 +1088,8 @@ mod tests { |
1088 | 1088 | None, |
1089 | 1089 | )) as ArrayRef; |
1090 | 1090 |
|
1091 | | - let to_write = RecordBatch::try_new(arrow_schema.clone(), vec![ |
1092 | | - float_32_col, |
1093 | | - float_64_col, |
1094 | | - ]) |
1095 | | - .unwrap(); |
| 1091 | + let to_write = |
| 1092 | + RecordBatch::try_new(arrow_schema.clone(), vec![float_32_col, float_64_col]).unwrap(); |
1096 | 1093 |
|
1097 | 1094 | // write data |
1098 | 1095 | let mut pw = ParquetWriterBuilder::new( |
@@ -1120,23 +1117,14 @@ mod tests { |
1120 | 1117 |
|
1121 | 1118 | // check data file |
1122 | 1119 | assert_eq!(data_file.record_count(), 4); |
1123 | | - assert_eq!( |
1124 | | - *data_file.value_counts(), |
1125 | | - HashMap::from([(0, 4), (1, 4)]) |
1126 | | - ); |
| 1120 | + assert_eq!(*data_file.value_counts(), HashMap::from([(0, 4), (1, 4)])); |
1127 | 1121 | assert_eq!( |
1128 | 1122 | *data_file.lower_bounds(), |
1129 | | - HashMap::from([ |
1130 | | - (0, Datum::float(1.0)), |
1131 | | - (1, Datum::double(1.0)), |
1132 | | - ]) |
| 1123 | + HashMap::from([(0, Datum::float(1.0)), (1, Datum::double(1.0)),]) |
1133 | 1124 | ); |
1134 | 1125 | assert_eq!( |
1135 | 1126 | *data_file.upper_bounds(), |
1136 | | - HashMap::from([ |
1137 | | - (0, Datum::float(2.0)), |
1138 | | - (1, Datum::double(2.0)), |
1139 | | - ]) |
| 1127 | + HashMap::from([(0, Datum::float(2.0)), (1, Datum::double(2.0)),]) |
1140 | 1128 | ); |
1141 | 1129 | assert_eq!( |
1142 | 1130 | *data_file.null_value_counts(), |
@@ -1265,23 +1253,14 @@ mod tests { |
1265 | 1253 |
|
1266 | 1254 | // check data file |
1267 | 1255 | assert_eq!(data_file.record_count(), 4); |
1268 | | - assert_eq!( |
1269 | | - *data_file.value_counts(), |
1270 | | - HashMap::from([(4, 4), (7, 4)]) |
1271 | | - ); |
| 1256 | + assert_eq!(*data_file.value_counts(), HashMap::from([(4, 4), (7, 4)])); |
1272 | 1257 | assert_eq!( |
1273 | 1258 | *data_file.lower_bounds(), |
1274 | | - HashMap::from([ |
1275 | | - (4, Datum::float(1.0)), |
1276 | | - (7, Datum::float(1.0)), |
1277 | | - ]) |
| 1259 | + HashMap::from([(4, Datum::float(1.0)), (7, Datum::float(1.0)),]) |
1278 | 1260 | ); |
1279 | 1261 | assert_eq!( |
1280 | 1262 | *data_file.upper_bounds(), |
1281 | | - HashMap::from([ |
1282 | | - (4, Datum::float(2.0)), |
1283 | | - (7, Datum::float(2.0)), |
1284 | | - ]) |
| 1263 | + HashMap::from([(4, Datum::float(2.0)), (7, Datum::float(2.0)),]) |
1285 | 1264 | ); |
1286 | 1265 | assert_eq!( |
1287 | 1266 | *data_file.null_value_counts(), |
@@ -1580,8 +1559,11 @@ mod tests { |
1580 | 1559 | None, |
1581 | 1560 | )) as ArrayRef; |
1582 | 1561 |
|
1583 | | - let to_write = RecordBatch::try_new(arrow_schema.clone(), vec![map_array, struct_list_float_field_col]) |
1584 | | - .expect("Could not form record batch"); |
| 1562 | + let to_write = RecordBatch::try_new(arrow_schema.clone(), vec![ |
| 1563 | + map_array, |
| 1564 | + struct_list_float_field_col, |
| 1565 | + ]) |
| 1566 | + .expect("Could not form record batch"); |
1585 | 1567 |
|
1586 | 1568 | // write data |
1587 | 1569 | let mut pw = ParquetWriterBuilder::new( |
@@ -1614,20 +1596,36 @@ mod tests { |
1614 | 1596 |
|
1615 | 1597 | // check data file |
1616 | 1598 | assert_eq!(data_file.record_count(), 4); |
1617 | | - assert_eq!(*data_file.value_counts(), HashMap::from([(1, 4), (2, 4), (6, 4), (7, 4)])); |
| 1599 | + assert_eq!( |
| 1600 | + *data_file.value_counts(), |
| 1601 | + HashMap::from([(1, 4), (2, 4), (6, 4), (7, 4)]) |
| 1602 | + ); |
1618 | 1603 | assert_eq!( |
1619 | 1604 | *data_file.lower_bounds(), |
1620 | | - HashMap::from([(1, Datum::int(1)), (2, Datum::float(1.0)), (6, Datum::int(1)), (7, Datum::float(1.0))]) |
| 1605 | + HashMap::from([ |
| 1606 | + (1, Datum::int(1)), |
| 1607 | + (2, Datum::float(1.0)), |
| 1608 | + (6, Datum::int(1)), |
| 1609 | + (7, Datum::float(1.0)) |
| 1610 | + ]) |
1621 | 1611 | ); |
1622 | 1612 | assert_eq!( |
1623 | 1613 | *data_file.upper_bounds(), |
1624 | | - HashMap::from([(1, Datum::int(4)), (2, Datum::float(2.0)), (6, Datum::int(4)), (7, Datum::float(2.0))]) |
| 1614 | + HashMap::from([ |
| 1615 | + (1, Datum::int(4)), |
| 1616 | + (2, Datum::float(2.0)), |
| 1617 | + (6, Datum::int(4)), |
| 1618 | + (7, Datum::float(2.0)) |
| 1619 | + ]) |
1625 | 1620 | ); |
1626 | 1621 | assert_eq!( |
1627 | 1622 | *data_file.null_value_counts(), |
1628 | 1623 | HashMap::from([(1, 0), (2, 0), (6, 0), (7, 0)]) |
1629 | 1624 | ); |
1630 | | - assert_eq!(*data_file.nan_value_counts(), HashMap::from([(2, 1), (7, 1)])); |
| 1625 | + assert_eq!( |
| 1626 | + *data_file.nan_value_counts(), |
| 1627 | + HashMap::from([(2, 1), (7, 1)]) |
| 1628 | + ); |
1631 | 1629 |
|
1632 | 1630 | // check the written file |
1633 | 1631 | let expect_batch = concat_batches(&arrow_schema, vec![&to_write]).unwrap(); |
|
0 commit comments