Skip to content

Support Temporal -> Utf8View casting #6734

Closed
@Omega359

Description

@Omega359

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Casting temporal to utf8view is not currently supported.

    #[test]
    fn test_cast_timestamp_to_strings() {
        // "2018-12-25T00:00:02.001", "1997-05-19T00:00:03.005", None
        let array =
            TimestampMillisecondArray::from(vec![Some(864000003005), Some(1545696002001), None]);
        let out = cast(&array, &DataType::Utf8).unwrap();
        let out = out
            .as_any()
            .downcast_ref::<StringArray>()
            .unwrap()
            .into_iter()
            .collect::<Vec<_>>();
        assert_eq!(
            out,
            vec![
                Some("1997-05-19T00:00:03.005"),
                Some("2018-12-25T00:00:02.001"),
                None
            ]
        );
        let out = cast(&array, &DataType::LargeUtf8).unwrap();
        let out = out
            .as_any()
            .downcast_ref::<LargeStringArray>()
            .unwrap()
            .into_iter()
            .collect::<Vec<_>>();
        assert_eq!(
            out,
            vec![
                Some("1997-05-19T00:00:03.005"),
                Some("2018-12-25T00:00:02.001"),
                None
            ]
        );

        let out = cast(&array, &DataType::Utf8View).unwrap();
        let out = out
            .as_any()
            .downcast_ref::<StringViewArray>()
            .unwrap()
            .into_iter()
            .collect::<Vec<_>>();
        assert_eq!(
            out,
            vec![
                Some("1997-05-19T00:00:03.005"),
                Some("2018-12-25T00:00:02.001"),
                None
            ]
        );
    }

CastError("Casting from Timestamp(Millisecond, None) to Utf8View not supported")

Describe the solution you'd like

Casting from temporal to utf8view arrays is supported.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions