Skip to content

Commit 2a937fe

Browse files
committed
fix fmt error
1 parent 205e40d commit 2a937fe

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

arrow-cast/src/cast/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,9 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
175175
// unsigned integer to decimal
176176
(UInt8 | UInt16 | UInt32 | UInt64, Decimal128(_, _)) |
177177
(UInt8 | UInt16 | UInt32 | UInt64, Decimal256(_, _)) |
178-
// unsigned integer to string
179-
(UInt8 | UInt16 | UInt32 | UInt64, Utf8View | Utf8 | LargeUtf8) |
180178
// signed numeric to decimal
181179
(Null | Int8 | Int16 | Int32 | Int64 | Float32 | Float64, Decimal128(_, _)) |
182180
(Null | Int8 | Int16 | Int32 | Int64 | Float32 | Float64, Decimal256(_, _)) |
183-
// signed numeric to string
184-
(Int8 | Int16 | Int32 | Int64 | Float16 | Float32 | Float64, Utf8View | Utf8 | LargeUtf8) |
185181
// decimal to unsigned numeric
186182
(Decimal128(_, _) | Decimal256(_, _), UInt8 | UInt16 | UInt32 | UInt64) |
187183
// decimal to signed numeric
@@ -235,7 +231,7 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
235231
(Utf8 | LargeUtf8, Utf8View) => true,
236232
(BinaryView, Binary | LargeBinary | Utf8 | LargeUtf8 | Utf8View ) => true,
237233
(Utf8 | LargeUtf8, _) => to_type.is_numeric() && to_type != &Float16,
238-
(_, Utf8 | LargeUtf8) => from_type.is_primitive(),
234+
(_, Utf8View | Utf8 | LargeUtf8) => from_type.is_primitive(),
239235

240236
(_, Binary | LargeBinary) => from_type.is_integer(),
241237

@@ -9157,6 +9153,15 @@ mod tests {
91579153

91589154
#[test]
91599155
fn test_cast_decimal_to_string() {
9156+
assert!(can_cast_types(
9157+
&DataType::Decimal128(10, 4),
9158+
&DataType::Utf8View
9159+
));
9160+
assert!(can_cast_types(
9161+
&DataType::Decimal256(38, 10),
9162+
&DataType::Utf8View
9163+
));
9164+
91609165
macro_rules! assert_decimal_values {
91619166
($array:expr) => {
91629167
let c = $array;
@@ -9208,9 +9213,6 @@ mod tests {
92089213
.map(|num| num.map(i256::from_i128))
92099214
.collect();
92109215

9211-
assert!(can_cast_types(&DataType::Decimal128(10, 4), &DataType::Utf8View));
9212-
assert!(can_cast_types(&DataType::Decimal256(38, 10), &DataType::Utf8View));
9213-
92149216
test_decimal_to_string::<Decimal128Type, i32>(
92159217
DataType::Utf8View,
92169218
create_decimal_array(array128.clone(), 7, 3).unwrap(),

0 commit comments

Comments
 (0)