Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
Description
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.
Unable to find source-code formatter for language: rust. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
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))
This prints:
Unable to find source-code formatter for language: text. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
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, ])
I would expect both comparison arrays to evaluate to true. This same effect is also occurring with utf8arrays.
Attachments
Issue Links
- links to