@@ -175,13 +175,9 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
175
175
// unsigned integer to decimal
176
176
( UInt8 | UInt16 | UInt32 | UInt64 , Decimal128 ( _, _) ) |
177
177
( UInt8 | UInt16 | UInt32 | UInt64 , Decimal256 ( _, _) ) |
178
- // unsigned integer to string
179
- ( UInt8 | UInt16 | UInt32 | UInt64 , Utf8View | Utf8 | LargeUtf8 ) |
180
178
// signed numeric to decimal
181
179
( Null | Int8 | Int16 | Int32 | Int64 | Float32 | Float64 , Decimal128 ( _, _) ) |
182
180
( Null | Int8 | Int16 | Int32 | Int64 | Float32 | Float64 , Decimal256 ( _, _) ) |
183
- // signed numeric to string
184
- ( Int8 | Int16 | Int32 | Int64 | Float16 | Float32 | Float64 , Utf8View | Utf8 | LargeUtf8 ) |
185
181
// decimal to unsigned numeric
186
182
( Decimal128 ( _, _) | Decimal256 ( _, _) , UInt8 | UInt16 | UInt32 | UInt64 ) |
187
183
// decimal to signed numeric
@@ -235,7 +231,7 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
235
231
( Utf8 | LargeUtf8 , Utf8View ) => true ,
236
232
( BinaryView , Binary | LargeBinary | Utf8 | LargeUtf8 | Utf8View ) => true ,
237
233
( Utf8 | LargeUtf8 , _) => to_type. is_numeric ( ) && to_type != & Float16 ,
238
- ( _, Utf8 | LargeUtf8 ) => from_type. is_primitive ( ) ,
234
+ ( _, Utf8View | Utf8 | LargeUtf8 ) => from_type. is_primitive ( ) ,
239
235
240
236
( _, Binary | LargeBinary ) => from_type. is_integer ( ) ,
241
237
@@ -9157,6 +9153,15 @@ mod tests {
9157
9153
9158
9154
#[ test]
9159
9155
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
+
9160
9165
macro_rules! assert_decimal_values {
9161
9166
( $array: expr) => {
9162
9167
let c = $array;
@@ -9208,9 +9213,6 @@ mod tests {
9208
9213
. map ( |num| num. map ( i256:: from_i128) )
9209
9214
. collect ( ) ;
9210
9215
9211
- assert ! ( can_cast_types( & DataType :: Decimal128 ( 10 , 4 ) , & DataType :: Utf8View ) ) ;
9212
- assert ! ( can_cast_types( & DataType :: Decimal256 ( 38 , 10 ) , & DataType :: Utf8View ) ) ;
9213
-
9214
9216
test_decimal_to_string :: < Decimal128Type , i32 > (
9215
9217
DataType :: Utf8View ,
9216
9218
create_decimal_array ( array128. clone ( ) , 7 , 3 ) . unwrap ( ) ,
0 commit comments