Skip to content

Scalar::is_zero is probably not correct for FixedSizeList and Struct #7891

Closed

Description

@connortsui20
    /// Returns `true` if the [`Scalar`] has a non-null zero value.
    ///
    /// Returns `None` if the scalar is null, otherwise returns `Some(true)` if the value is zero
    /// and `Some(false)` otherwise.
    pub fn is_zero(&self) -> Option<bool> {
        let value = self.value()?;

        let is_zero = match self.dtype() {
            ...
            DType::FixedSizeList(_, list_size, _) => value.as_list().len() == *list_size as usize,
            DType::Struct(struct_fields, _) => value.as_list().len() == struct_fields.nfields(),
            ...
        };

        Some(is_zero)
    }

I'm pretty sure this is wrong. We need to check these are true but also that the elements themselves are zero.

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

    bugA bug issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions