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

Function test_parse_timestamp_impl

arrow-csv/src/reader/mod.rs:2028–2056  ·  view source on GitHub ↗
(
        timezone: Option<Arc<str>>,
        expected: &[i64],
    )

Source from the content-addressed store, hash-verified

2026 }
2027
2028 fn test_parse_timestamp_impl<T: ArrowTimestampType>(
2029 timezone: Option<Arc<str>>,
2030 expected: &[i64],
2031 ) {
2032 let csv = [
2033 "1970-01-01T00:00:00",
2034 "1970-01-01T00:00:00Z",
2035 "1970-01-01T00:00:00+02:00",
2036 ]
2037 .join("\n");
2038 let schema = Arc::new(Schema::new(vec![Field::new(
2039 "field",
2040 DataType::Timestamp(T::UNIT, timezone.clone()),
2041 true,
2042 )]));
2043
2044 let mut decoder = ReaderBuilder::new(schema).build_decoder();
2045
2046 let decoded = decoder.decode(csv.as_bytes()).unwrap();
2047 assert_eq!(decoded, csv.len());
2048 decoder.decode(&[]).unwrap();
2049
2050 let batch = decoder.flush().unwrap().unwrap();
2051 assert_eq!(batch.num_columns(), 1);
2052 assert_eq!(batch.num_rows(), 3);
2053 let col = batch.column(0).as_primitive::<T>();
2054 assert_eq!(col.values(), expected);
2055 assert_eq!(col.data_type(), &DataType::Timestamp(T::UNIT, timezone));
2056 }
2057
2058 #[test]
2059 fn test_parse_timestamp() {

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
build_decoderMethod · 0.45
decodeMethod · 0.45
as_bytesMethod · 0.45
flushMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected