Skip to content

Commit 67c1655

Browse files
fix: add validity no_nulls and fix usage (#7487)
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 91b4c75 commit 67c1655

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

vortex-array/public-api.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19038,6 +19038,8 @@ pub fn vortex_array::validity::Validity::mask_eq(&self, other: &vortex_array::va
1903819038

1903919039
pub fn vortex_array::validity::Validity::maybe_len(&self) -> core::option::Option<usize>
1904019040

19041+
pub fn vortex_array::validity::Validity::no_nulls(&self) -> bool
19042+
1904119043
pub fn vortex_array::validity::Validity::not(&self) -> vortex_error::VortexResult<Self>
1904219044

1904319045
pub fn vortex_array::validity::Validity::nullability(&self) -> vortex_array::dtype::Nullability

vortex-array/src/arrow/record_batch.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use crate::VortexSessionExecute;
1717
use crate::array::IntoArray;
1818
use crate::arrays::StructArray;
1919
use crate::arrow::ArrowArrayExecutor;
20-
use crate::validity::Validity;
2120

2221
// deprecated(note = "Use ArrowArrayExecutor::execute_record_batch instead")
2322
impl TryFrom<&ArrayRef> for RecordBatch {
@@ -29,7 +28,7 @@ impl TryFrom<&ArrayRef> for RecordBatch {
2928
};
3029

3130
vortex_ensure!(
32-
matches!(struct_array.validity()?, Validity::AllValid),
31+
struct_array.validity()?.no_nulls(),
3332
"RecordBatch can only be constructed from StructArray with no nulls"
3433
);
3534

vortex-array/src/validity.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ impl Validity {
112112
}
113113
}
114114

115+
/// Returns `true` if this validity guarantees no null values, i.e. it is either
116+
/// [`Validity::NonNullable`] or [`Validity::AllValid`].
117+
#[inline]
118+
pub fn no_nulls(&self) -> bool {
119+
matches!(self, Self::NonNullable | Self::AllValid)
120+
}
121+
115122
/// The union nullability and validity.
116123
#[inline]
117124
pub fn union_nullability(self, nullability: Nullability) -> Self {

0 commit comments

Comments
 (0)