Skip to content

Take on strings incorrect on slices #1049

@bjchambers

Description

@bjchambers

Describe the bug

#[test]
fn test_take_slice_string() {
    let strings =
        StringArray::from(vec![Some("hello"), None, Some("world"), None, Some("hi")]);
    let indices = Int32Array::from(vec![Some(0), Some(1), None, Some(0), Some(2)]);
    let indices_slice = indices.slice(1, 4);
    let indices_slice = indices_slice
        .as_ref()
        .as_any()
        .downcast_ref::<Int32Array>()
        .unwrap();

    let expected = StringArray::from(vec![None, None, Some("hello"), Some("world")]);
    let result = take(&strings, indices_slice, None).unwrap();
    assert_eq!(result.as_ref(), &expected);
}
thread 'compute::kernels::take::tests::test_take_slice_string' panicked at 'assertion failed: `(left == right)`
  left: `StringArray
[
  null,
  null,
  null,
  "world",
]`,
 right: `StringArray
[
  null,
  null,
  "hello",
  "world",
]`', arrow/src/compute/kernels/take.rs:1950:9

To Reproduce

See test. It looks like the null bits aren't being properly shifted when used in the take kernel.

Expected behavior

Test passes.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions