[ 
https://issues.apache.org/jira/browse/ARROW-9503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chao Sun resolved ARROW-9503.
-----------------------------
    Fix Version/s: 1.0.0
       Resolution: Fixed

Issue resolved by pull request 7788
[https://github.com/apache/arrow/pull/7788]

> [Rust] Comparison sliced arrays is wrong
> ----------------------------------------
>
>                 Key: ARROW-9503
>                 URL: https://issues.apache.org/jira/browse/ARROW-9503
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Rust
>            Reporter: Ritchie
>            Assignee: Paddy Horan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.0.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Comparison of arrow arrays where one is sliced is dependent on the order of 
> comparison, and doesn't always yield correct results.
> The following minimal example shows the differing results.
> {code:rust}
>         use arrow::{
>             datatypes::Int32Type,
>             compute,
>             array::{
>                 Array,
>                 PrimitiveBuilder,
>                 PrimitiveArray
>             }
>         };
>         let mut builder = PrimitiveBuilder::new(10);
>         for v in 0..10 {
>             builder.append_value(v).unwrap()
>         }
>         let a: PrimitiveArray<Int32Type> = builder.finish();
>         let mut builder = PrimitiveBuilder::new(10);
>         for v in 5..10 {
>             builder.append_value(v).unwrap()
>         }
>         let b: PrimitiveArray<Int32Type> = builder.finish();
>         // returns Array trait
>         let sliced_a = a.slice(5, 5);
>         // Downcast to PrimitiveArray
>         let sliced_a = sliced_a.as_any().downcast_ref().unwrap();
>         println!("{:?}", a.slice(5, 5));
>         println!("{:?}", b);
>         println!("{:?}", compute::eq(sliced_a, &b));
>         println!("{:?}", compute::eq(&b, sliced_a))
> {code}
> This prints:
> {code:text}
> PrimitiveArray<Int32>
> [
>   5,
>   6,
>   7,
>   8,
>   9,
> ]
> PrimitiveArray<Int32>
> [
>   5,
>   6,
>   7,
>   8,
>   9,
> ]
> Ok(PrimitiveArray<Boolean>
> [
>   false,
>   false,
>   false,
>   false,
>   false,
> ])
> Ok(PrimitiveArray<Boolean>
> [
>   true,
>   true,
>   true,
>   true,
>   true,
> ])
> {code}
> I would expect both comparison arrays to evaluate to true. This same effect 
> is also occurring with utf8arrays.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to