From f936d83755091ed8cbaea4bac66df5e24718c62a Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Thu, 13 Jan 2022 06:40:05 +0000 Subject: [PATCH] Added test --- tests/it/compute/cast.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/it/compute/cast.rs b/tests/it/compute/cast.rs index 5c8298c04e9..0833d113608 100644 --- a/tests/it/compute/cast.rs +++ b/tests/it/compute/cast.rs @@ -312,6 +312,21 @@ fn decimal_to_decimal_scaled() { assert_eq!(c, &expected) } +#[test] +fn decimal_to_decimal_fast() { + // increase precision + // 10 and -10 can't be represented with precision 1 and scale 1 + let array = Int128Array::from(&[Some(2), Some(10), Some(-2), Some(-10), None]) + .to(DataType::Decimal(1, 1)); + + let b = cast(&array, &DataType::Decimal(2, 1), CastOptions::default()).unwrap(); + let c = b.as_any().downcast_ref::>().unwrap(); + + let expected = Int128Array::from(&[Some(2), Some(10), Some(-2), Some(-10), None]) + .to(DataType::Decimal(2, 1)); + assert_eq!(c, &expected) +} + #[test] fn decimal_to_float() { let array = Int128Array::from(&[Some(2), Some(10), Some(-2), Some(-10), None])