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

Function test_json_basic_with_nulls

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

Source from the content-addressed store, hash-verified

1944
1945 #[test]
1946 fn test_json_basic_with_nulls() {
1947 let mut reader = read_file("test/data/basic_nulls.json", None);
1948 let batch = reader.next().unwrap().unwrap();
1949
1950 assert_eq!(4, batch.num_columns());
1951 assert_eq!(12, batch.num_rows());
1952
1953 let schema = reader.schema();
1954 let batch_schema = batch.schema();
1955 assert_eq!(schema, batch_schema);
1956
1957 let a = schema.column_with_name("a").unwrap();
1958 assert_eq!(&DataType::Int64, a.1.data_type());
1959 let b = schema.column_with_name("b").unwrap();
1960 assert_eq!(&DataType::Float64, b.1.data_type());
1961 let c = schema.column_with_name("c").unwrap();
1962 assert_eq!(&DataType::Boolean, c.1.data_type());
1963 let d = schema.column_with_name("d").unwrap();
1964 assert_eq!(&DataType::Utf8, d.1.data_type());
1965
1966 let aa = batch.column(a.0).as_primitive::<Int64Type>();
1967 assert!(aa.is_valid(0));
1968 assert!(!aa.is_valid(1));
1969 assert!(!aa.is_valid(11));
1970 let bb = batch.column(b.0).as_primitive::<Float64Type>();
1971 assert!(bb.is_valid(0));
1972 assert!(!bb.is_valid(2));
1973 assert!(!bb.is_valid(11));
1974 let cc = batch.column(c.0).as_boolean();
1975 assert!(cc.is_valid(0));
1976 assert!(!cc.is_valid(4));
1977 assert!(!cc.is_valid(11));
1978 let dd = batch.column(d.0).as_string::<i32>();
1979 assert!(!dd.is_valid(0));
1980 assert!(dd.is_valid(1));
1981 assert!(!dd.is_valid(4));
1982 assert!(!dd.is_valid(11));
1983 }
1984
1985 #[test]
1986 fn test_json_basic_schema() {

Callers

nothing calls this directly

Calls 6

column_with_nameMethod · 0.80
read_fileFunction · 0.70
nextMethod · 0.45
schemaMethod · 0.45
columnMethod · 0.45
as_booleanMethod · 0.45

Tested by

no test coverage detected