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

Function test_init_nulls_with_inference

arrow-csv/src/reader/mod.rs:1703–1731  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1701
1702 #[test]
1703 fn test_init_nulls_with_inference() {
1704 let format = Format::default().with_header(true).with_delimiter(b',');
1705
1706 let mut file = File::open("test/data/init_null_test.csv").unwrap();
1707 let (schema, _) = format.infer_schema(&mut file, None).unwrap();
1708 file.rewind().unwrap();
1709
1710 let expected_schema = Schema::new(vec![
1711 Field::new("c_int", DataType::Int64, true),
1712 Field::new("c_float", DataType::Float64, true),
1713 Field::new("c_string", DataType::Utf8, true),
1714 Field::new("c_bool", DataType::Boolean, true),
1715 Field::new("c_null", DataType::Null, true),
1716 ]);
1717 assert_eq!(schema, expected_schema);
1718
1719 let mut csv = ReaderBuilder::new(Arc::new(schema))
1720 .with_format(format)
1721 .build(file)
1722 .unwrap();
1723
1724 let batch = csv.next().unwrap().unwrap();
1725
1726 assert!(batch.column(1).is_null(0));
1727 assert!(!batch.column(1).is_null(1));
1728 assert!(batch.column(1).is_null(2));
1729 assert!(!batch.column(1).is_null(3));
1730 assert!(!batch.column(1).is_null(4));
1731 }
1732
1733 #[test]
1734 fn test_custom_nulls() {

Callers

nothing calls this directly

Calls 7

defaultFunction · 0.85
infer_schemaMethod · 0.80
with_formatMethod · 0.80
with_delimiterMethod · 0.45
with_headerMethod · 0.45
buildMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected