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

Function test_csv_with_nullable_dictionary

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

Source from the content-addressed store, hash-verified

1617
1618 #[test]
1619 fn test_csv_with_nullable_dictionary() {
1620 let offset_type = vec![
1621 DataType::Int8,
1622 DataType::Int16,
1623 DataType::Int32,
1624 DataType::Int64,
1625 DataType::UInt8,
1626 DataType::UInt16,
1627 DataType::UInt32,
1628 DataType::UInt64,
1629 ];
1630 for data_type in offset_type {
1631 let file = File::open("test/data/dictionary_nullable_test.csv").unwrap();
1632 let dictionary_type =
1633 DataType::Dictionary(Box::new(data_type), Box::new(DataType::Utf8));
1634 let schema = Arc::new(Schema::new(vec![
1635 Field::new("id", DataType::Utf8, false),
1636 Field::new("name", dictionary_type.clone(), true),
1637 ]));
1638
1639 let mut csv = ReaderBuilder::new(schema)
1640 .build(file.try_clone().unwrap())
1641 .unwrap();
1642
1643 let batch = csv.next().unwrap().unwrap();
1644 assert_eq!(3, batch.num_rows());
1645 assert_eq!(2, batch.num_columns());
1646
1647 let names = arrow_cast::cast(batch.column(1), &dictionary_type).unwrap();
1648 assert!(!names.is_null(2));
1649 assert!(names.is_null(1));
1650 }
1651 }
1652 #[test]
1653 fn test_nulls() {
1654 let schema = Arc::new(Schema::new(vec![

Callers

nothing calls this directly

Calls 4

castFunction · 0.85
buildMethod · 0.45
nextMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected