Skip to content

Equality semantics in Vortex #8826

Closed
Closed

Description

@connortsui20

It is not immediately obvious what we define as "equal" in Vortex, especially with nullability involved.

A good demonstration of our current semantics on develop are:

impl PartialEq for Scalar {
    fn eq(&self, other: &Self) -> bool {
        self.dtype.eq_ignore_nullability(&other.dtype)
            && self.value == other.value                // where `value` is `Option`
    }
}

We define equality over scalars as equality that ignores the nullability. This is useful because ideally, we want to say that a scalar that has type i32? (nullable integer) that has value 42 (a non-null value even though it is allowed to be null) is equal to the value 42, even if the type is non-nullable.

This logic can then be extended to arrays, where arrays should have the same semantics as a list of scalars.

I think this is an apt description, but other people might have different opinions. And it doesn't seem like we all agree that this is the correct semantics that we want.

cc @joseph-isaacs @robert3005

Activity

  1. robert3005 commented on Jul 20, 2026

    @robert3005
    Contributor

    I think the semantics are correct. The discussion we had in community slack was trying to understand what drives the scalar equality semantics and we have convinced ourselves there that we understand it enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions