Skip to content

[Rust] pitfall in xxx_equal functions #27069

@asfimport

Description

@asfimport

Functions pub(super) fn xxxx_equal in rust/src/array/equal/ MUST fail if called directly instead of from equal.  boolean.rs as  example:

lhs_is_null || (lhs_is_null == rhs_is_null)
 && equal_bits(...)

 
The bug is not seen in tests at present because equal shortcuts the condition: zero nulls v.s. nulls
 
To verify this problem , adds a new test in mod.rs
 

#[test]
fn test_direct_call_boolean_equal() {
    let a = BooleanArray::from(vec![Some(true)]).data();
    let b = BooleanArray::from(vec![Some(false)]).data();
    let lhs = a.as_ref();
    let rhs = b.as_ref();
    let lhs_nulls = lhs.null_buffer();
    let rhs_nulls = rhs.null_buffer();
    assert_eq!(boolean::boolean_equal(lhs, rhs, lhs_nulls, rhs_nulls, 0, 0, lhs.len()), false);
}

Reporter: Qingyou Meng / @mqy

Related issues:

Note: This issue was originally created as ARROW-11160. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions