MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_json_iterator

Function test_json_iterator

arrow-json/src/reader/mod.rs:2647–2674  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2645
2646 #[test]
2647 fn test_json_iterator() {
2648 let file = File::open("test/data/basic.json").unwrap();
2649 let mut reader = BufReader::new(file);
2650 let (schema, _) = infer_json_schema(&mut reader, None).unwrap();
2651 reader.rewind().unwrap();
2652
2653 let builder = ReaderBuilder::new(Arc::new(schema)).with_batch_size(5);
2654 let reader = builder.build(reader).unwrap();
2655 let schema = reader.schema();
2656 let (col_a_index, _) = schema.column_with_name("a").unwrap();
2657
2658 let mut sum_num_rows = 0;
2659 let mut num_batches = 0;
2660 let mut sum_a = 0;
2661 for batch in reader {
2662 let batch = batch.unwrap();
2663 assert_eq!(8, batch.num_columns());
2664 sum_num_rows += batch.num_rows();
2665 num_batches += 1;
2666 let batch_schema = batch.schema();
2667 assert_eq!(schema, batch_schema);
2668 let a_array = batch.column(col_a_index).as_primitive::<Int64Type>();
2669 sum_a += (0..a_array.len()).map(|i| a_array.value(i)).sum::<i64>();
2670 }
2671 assert_eq!(12, sum_num_rows);
2672 assert_eq!(3, num_batches);
2673 assert_eq!(100000000000011, sum_a);
2674 }
2675
2676 #[test]
2677 fn test_decoder_error() {

Callers

nothing calls this directly

Calls 9

infer_json_schemaFunction · 0.85
column_with_nameMethod · 0.80
with_batch_sizeMethod · 0.45
buildMethod · 0.45
schemaMethod · 0.45
num_rowsMethod · 0.45
columnMethod · 0.45
lenMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected