Skip to content

Commit 72bee56

Browse files
authored
fix: StructArray with empty fields is considered constant (#3895)
1 parent c886f1c commit 72bee56

File tree

1 file changed

+10
-3
lines changed
  • vortex-array/src/arrays/struct_/compute

1 file changed

+10
-3
lines changed

vortex-array/src/arrays/struct_/compute/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl IsConstantKernel for StructVTable {
7171
) -> VortexResult<Option<bool>> {
7272
let children = array.children();
7373
if children.is_empty() {
74-
return Ok(None);
74+
return Ok(Some(true));
7575
}
7676

7777
for child in children.iter() {
@@ -91,16 +91,16 @@ register_kernel!(IsConstantKernelAdapter(StructVTable).lift());
9191

9292
#[cfg(test)]
9393
mod tests {
94-
9594
use Nullability::{NonNullable, Nullable};
9695
use vortex_buffer::buffer;
9796
use vortex_dtype::{DType, FieldNames, Nullability, PType, StructFields};
97+
use vortex_error::VortexUnwrap;
9898
use vortex_mask::Mask;
9999
use vortex_scalar::Scalar;
100100

101101
use crate::arrays::{BoolArray, BooleanBuffer, PrimitiveArray, StructArray, VarBinArray};
102102
use crate::compute::conformance::mask::test_mask;
103-
use crate::compute::{cast, filter, take};
103+
use crate::compute::{cast, filter, is_constant, take};
104104
use crate::validity::Validity;
105105
use crate::{Array, IntoArray as _};
106106

@@ -343,4 +343,11 @@ mod tests {
343343
let casted = cast(&fully_nullable_array, &non_null_xs).unwrap();
344344
assert_eq!(casted.dtype(), &non_null_xs);
345345
}
346+
347+
#[test]
348+
fn test_empty_struct_is_constant() {
349+
let array = StructArray::new_with_len(2);
350+
let is_constant = is_constant(array.as_ref()).vortex_unwrap();
351+
assert_eq!(is_constant, Some(true));
352+
}
346353
}

0 commit comments

Comments
 (0)