()
| 1529 | |
| 1530 | #[test] |
| 1531 | fn test_csv_builder_with_bounds() { |
| 1532 | let mut file = File::open("test/data/uk_cities.csv").unwrap(); |
| 1533 | |
| 1534 | // Set the bounds to the lines 0, 1 and 2. |
| 1535 | let (schema, _) = Format::default().infer_schema(&mut file, None).unwrap(); |
| 1536 | file.rewind().unwrap(); |
| 1537 | let mut csv = ReaderBuilder::new(Arc::new(schema)) |
| 1538 | .with_bounds(0, 2) |
| 1539 | .build(file) |
| 1540 | .unwrap(); |
| 1541 | let batch = csv.next().unwrap().unwrap(); |
| 1542 | |
| 1543 | // access data from a string array (ListArray<u8>) |
| 1544 | let city = batch |
| 1545 | .column(0) |
| 1546 | .as_any() |
| 1547 | .downcast_ref::<StringArray>() |
| 1548 | .unwrap(); |
| 1549 | |
| 1550 | // The value on line 0 is within the bounds |
| 1551 | assert_eq!("Elgin, Scotland, the UK", city.value(0)); |
| 1552 | |
| 1553 | // The value on line 13 is outside of the bounds. Therefore |
| 1554 | // the call to .value() will panic. |
| 1555 | let result = std::panic::catch_unwind(|| city.value(13)); |
| 1556 | assert!(result.is_err()); |
| 1557 | } |
| 1558 | |
| 1559 | #[test] |
| 1560 | fn test_csv_with_projection() { |
nothing calls this directly
no test coverage detected