Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Jan 13, 2022
1 parent 4919a9d commit f936d83
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/it/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<PrimitiveArray<i128>>().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])
Expand Down

0 comments on commit f936d83

Please sign in to comment.