From 83699a3fdde7385bacec38739c6605c7a7659020 Mon Sep 17 00:00:00 2001 From: Kaifeng Zheng Date: Thu, 12 Dec 2024 16:41:38 +0800 Subject: [PATCH] enable matching temporal from_type --- arrow-cast/src/cast/mod.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs index 0a44392a245..8b07f847c2e 100644 --- a/arrow-cast/src/cast/mod.rs +++ b/arrow-cast/src/cast/mod.rs @@ -1472,7 +1472,7 @@ pub fn cast_with_options( (BinaryView, _) => Err(ArrowError::CastError(format!( "Casting from {from_type:?} to {to_type:?} not supported", ))), - (from_type, Utf8View) if from_type.is_numeric() => { + (from_type, Utf8View) if from_type.is_primitive() => { value_to_string_view(array, cast_options) } (from_type, LargeUtf8) if from_type.is_primitive() => { @@ -5295,7 +5295,7 @@ mod tests { None, ]; - // assert_cast_timestamp_to_string!(array, DataType::Utf8View, StringViewArray, expected); + assert_cast_timestamp_to_string!(array, DataType::Utf8View, StringViewArray, expected); assert_cast_timestamp_to_string!(array, DataType::Utf8, StringArray, expected); assert_cast_timestamp_to_string!(array, DataType::LargeUtf8, LargeStringArray, expected); } @@ -5319,7 +5319,13 @@ mod tests { Some("2018-12-25 00:00:02.001000"), None, ]; - // assert_cast_timestamp_to_string!(array_without_tz, DataType::Utf8View, StringViewArray, cast_options, expected); + assert_cast_timestamp_to_string!( + array_without_tz, + DataType::Utf8View, + StringViewArray, + cast_options, + expected + ); assert_cast_timestamp_to_string!( array_without_tz, DataType::Utf8, @@ -5343,7 +5349,13 @@ mod tests { Some("2018-12-25 05:45:02.001000"), None, ]; - // assert_cast_timestamp_to_string!(array_with_tz, DataType::Utf8View, StringViewArray, cast_options, expected); + assert_cast_timestamp_to_string!( + array_with_tz, + DataType::Utf8View, + StringViewArray, + cast_options, + expected + ); assert_cast_timestamp_to_string!( array_with_tz, DataType::Utf8,