Skip to content

Support Temporal -> Utf8View casting #6734

Closed

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

Activity

  1. Omega359 commented on Nov 15, 2024

    @Omega359
    ContributorAuthor

    This came up as part of a review in #6719

  2. alamb commented on Dec 17, 2024

    @alamb
    Contributor

    label_issue.py automatically added labels {'arrow'} from #6872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow crateenhancementNew feature/addition

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions