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

arrow-ord: Comparison for struct #5411

Open
jayzhan211 opened this issue Feb 20, 2024 · 1 comment
Open

arrow-ord: Comparison for struct #5411

jayzhan211 opened this issue Feb 20, 2024 · 1 comment
Assignees
Labels
enhancement Any new improvement worthy of a entry in the changelog

Comments

@jayzhan211
Copy link
Contributor

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

Describe the solution you'd like

similar to #5407 but for struct
We can have eq first which fix apache/datafusion#9254

Pass this test

    #[test]
    fn test_struct_ord() {
        let s1 = StructArray::try_from(vec![
            (
                "a",
                Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5])) as Arc<dyn Array>,
            ),
            (
                "b",
                Arc::new(Float32Array::from(vec![1.0, 2.0, 3.0, 4.0, 5.0])) as Arc<dyn Array>,
            )
        ]).unwrap();
        let s2 = StructArray::try_from(vec![
            (
                "a",
                Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5])) as Arc<dyn Array>,
            ),
            (
                "b",
                Arc::new(Float32Array::from(vec![1.0, 2.0, 3.0, 4.0, 5.0])) as Arc<dyn Array>,
            )
        ]).unwrap();

        let res = eq(&s1, &s2).unwrap();
        println!("res: {:?}", res);
    }

Describe alternatives you've considered

Additional context

@jayzhan211 jayzhan211 added the enhancement Any new improvement worthy of a entry in the changelog label Feb 20, 2024
@tustvold
Copy link
Contributor

tustvold commented Feb 20, 2024

This should be a relatively straightforward case of recursing for each of the fields and then combining the results based on the operation. Unlike ListArray, it shouldn't necessary to use DynComparator as the indices to compare are aligned

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

2 participants