Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Temporal -> Utf8View casting #6734

Open
Omega359 opened this issue Nov 15, 2024 · 1 comment
Open

Support Temporal -> Utf8View casting #6734

Omega359 opened this issue Nov 15, 2024 · 1 comment
Labels
enhancement Any new improvement worthy of a entry in the changelog

Comments

@Omega359
Copy link
Contributor

Omega359 commented Nov 15, 2024

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

@Omega359 Omega359 added the enhancement Any new improvement worthy of a entry in the changelog label Nov 15, 2024
@Omega359
Copy link
Contributor Author

This came up as part of a review in #6719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

No branches or pull requests

1 participant