From 74bc486b9ae1d0ed94b97d02c3c481d0aff2087a Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 5 Jun 2024 14:21:29 +0200 Subject: [PATCH] Add tests for milliseconds and microseconds --- tests/basic/main.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/basic/main.rs b/tests/basic/main.rs index d11a105d..402bfc47 100644 --- a/tests/basic/main.rs +++ b/tests/basic/main.rs @@ -420,14 +420,28 @@ pub fn overflowing_timestamps_test() { } #[test] -pub fn custom_precision_timestamps_test() { +pub fn second_timestamps_test() { + custom_precision_timestamps_test(TimeUnit::Second) +} + +#[test] +pub fn millisecond_timestamps_test() { + custom_precision_timestamps_test(TimeUnit::Millisecond) +} + +#[test] +pub fn microsecond_timestamps_test() { + custom_precision_timestamps_test(TimeUnit::Microsecond) +} + +fn custom_precision_timestamps_test(time_unit: TimeUnit) { let path = basic_path("overflowing_timestamps.orc"); let f = File::open(path).expect("no file found"); let reader = ArrowReaderBuilder::try_new(f) .unwrap() .with_schema(Arc::new(Schema::new(vec![ Field::new("id", DataType::Int32, true), - Field::new("ts", DataType::Timestamp(TimeUnit::Second, None), true), + Field::new("ts", DataType::Timestamp(time_unit, None), true), ]))) .build(); let batch = reader.collect::, _>>().unwrap();