Skip to content

Commit

Permalink
Enable matching temporal as from_type to Utf8View (#6872)
Browse files Browse the repository at this point in the history
* enable matching temporal from_type

* drop todo message
  • Loading branch information
Kev1n8 authored Dec 12, 2024
1 parent 4acf4d3 commit e613622
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions arrow-cast/src/cast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() => {
Expand Down Expand Up @@ -5258,9 +5258,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();
Expand Down Expand Up @@ -5295,7 +5292,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);
}
Expand All @@ -5319,7 +5316,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,
Expand All @@ -5343,7 +5346,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,
Expand Down

0 comments on commit e613622

Please sign in to comment.