Skip to content

Commit 181e52e

Browse files
alambKev1n8
andauthored
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]>
1 parent b66fb90 commit 181e52e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

arrow-cast/src/cast/mod.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ pub fn cast_with_options(
14671467
(BinaryView, _) => Err(ArrowError::CastError(format!(
14681468
"Casting from {from_type:?} to {to_type:?} not supported",
14691469
))),
1470-
(from_type, Utf8View) if from_type.is_numeric() => {
1470+
(from_type, Utf8View) if from_type.is_primitive() => {
14711471
value_to_string_view(array, cast_options)
14721472
}
14731473
(from_type, LargeUtf8) if from_type.is_primitive() => {
@@ -5240,9 +5240,6 @@ mod tests {
52405240
assert_eq!("2018-12-25T00:00:00", c.value(1));
52415241
}
52425242

5243-
// Cast Timestamp to Utf8View is not supported yet
5244-
// TODO: Implement casting from Timestamp to Utf8View
5245-
// https://github.com/apache/arrow-rs/issues/6734
52465243
macro_rules! assert_cast_timestamp_to_string {
52475244
($array:expr, $datatype:expr, $output_array_type: ty, $expected:expr) => {{
52485245
let out = cast(&$array, &$datatype).unwrap();
@@ -5277,7 +5274,7 @@ mod tests {
52775274
None,
52785275
];
52795276

5280-
// assert_cast_timestamp_to_string!(array, DataType::Utf8View, StringViewArray, expected);
5277+
assert_cast_timestamp_to_string!(array, DataType::Utf8View, StringViewArray, expected);
52815278
assert_cast_timestamp_to_string!(array, DataType::Utf8, StringArray, expected);
52825279
assert_cast_timestamp_to_string!(array, DataType::LargeUtf8, LargeStringArray, expected);
52835280
}
@@ -5301,7 +5298,13 @@ mod tests {
53015298
Some("2018-12-25 00:00:02.001000"),
53025299
None,
53035300
];
5304-
// assert_cast_timestamp_to_string!(array_without_tz, DataType::Utf8View, StringViewArray, cast_options, expected);
5301+
assert_cast_timestamp_to_string!(
5302+
array_without_tz,
5303+
DataType::Utf8View,
5304+
StringViewArray,
5305+
cast_options,
5306+
expected
5307+
);
53055308
assert_cast_timestamp_to_string!(
53065309
array_without_tz,
53075310
DataType::Utf8,
@@ -5325,7 +5328,13 @@ mod tests {
53255328
Some("2018-12-25 05:45:02.001000"),
53265329
None,
53275330
];
5328-
// assert_cast_timestamp_to_string!(array_with_tz, DataType::Utf8View, StringViewArray, cast_options, expected);
5331+
assert_cast_timestamp_to_string!(
5332+
array_with_tz,
5333+
DataType::Utf8View,
5334+
StringViewArray,
5335+
cast_options,
5336+
expected
5337+
);
53295338
assert_cast_timestamp_to_string!(
53305339
array_with_tz,
53315340
DataType::Utf8,

0 commit comments

Comments
 (0)