This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch 53.0.0_maintenance
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/53.0.0_maintenance by this 
push:
     new 181e52e213 Enable matching temporal as from_type to Utf8View (#6872) 
(#6956)
181e52e213 is described below

commit 181e52e2138b7aec96b93066d7394b3699f07f36
Author: Andrew Lamb <[email protected]>
AuthorDate: Fri Jan 10 09:12:38 2025 -0500

    Enable matching temporal as from_type to Utf8View (#6872) (#6956)
    
    * enable matching temporal from_type
    
    * drop todo message
    
    Co-authored-by: Kaifeng Zheng <[email protected]>
---
 arrow-cast/src/cast/mod.rs | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index 5e307022df..57694b1c63 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -1467,7 +1467,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() => {
@@ -5240,9 +5240,6 @@ mod tests {
         assert_eq!("2018-12-25T00:00:00", c.value(1));
     }
 
-    // Cast Timestamp to Utf8View is not supported yet
-    // TODO: Implement casting from Timestamp to Utf8View
-    // https://github.com/apache/arrow-rs/issues/6734
     macro_rules! assert_cast_timestamp_to_string {
         ($array:expr, $datatype:expr, $output_array_type: ty, $expected:expr) 
=> {{
             let out = cast(&$array, &$datatype).unwrap();
@@ -5277,7 +5274,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);
     }
@@ -5301,7 +5298,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,
@@ -5325,7 +5328,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,

Reply via email to