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

Function test_timestamp_from_json_seconds

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

Source from the content-addressed store, hash-verified

2523
2524 #[test]
2525 fn test_timestamp_from_json_seconds() {
2526 let schema = Schema::new(vec![Field::new(
2527 "a",
2528 DataType::Timestamp(TimeUnit::Second, None),
2529 true,
2530 )]);
2531
2532 let mut reader = read_file("test/data/basic_nulls.json", Some(schema));
2533 let batch = reader.next().unwrap().unwrap();
2534
2535 assert_eq!(1, batch.num_columns());
2536 assert_eq!(12, batch.num_rows());
2537
2538 let schema = reader.schema();
2539 let batch_schema = batch.schema();
2540 assert_eq!(schema, batch_schema);
2541
2542 let a = schema.column_with_name("a").unwrap();
2543 assert_eq!(
2544 &DataType::Timestamp(TimeUnit::Second, None),
2545 a.1.data_type()
2546 );
2547
2548 let aa = batch.column(a.0).as_primitive::<TimestampSecondType>();
2549 assert!(aa.is_valid(0));
2550 assert!(!aa.is_valid(1));
2551 assert!(!aa.is_valid(2));
2552 assert_eq!(1, aa.value(0));
2553 assert_eq!(1, aa.value(3));
2554 assert_eq!(5, aa.value(7));
2555 }
2556
2557 #[test]
2558 fn test_timestamp_from_json_milliseconds() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected